I have a PowerShell script containing the following logging function:
function LogError([string] $message, $exception = $null) {…}
In a try-catch block, when an exception occurs, I call that logging function like this:
catch { LogError("…", $_.Exception) }
In the LogError function, the second argument is always $null. Why?
I couldn't find any documentation that would explain why I cannot use $_.Exception in a function call or that I am supposed to use instead.