I have a PS module that contains several scripts for individual functions. There is also a βlibraryβ script with a number of helper functions called by the functions used in the module.
Let the external ReadWeb function be ReadWeb , and it uses the ParseXML helper function.
This week I ran into an error handling issue in the ParseXML internal helper function. This function contains try / catch, and in catch I will interrogate:
$Error[0].Exception.InnerException.Message
... to pass the error back to the outside as a variable and determine if ParseXML is ParseXML .
In a specific case, I was getting an indexing error when I called ReadWeb . The root cause was the $Error object in the Catch block in ParseXML $Null returned.
I changed the error handling to check $Error -eq $Null , and if so, use $_ in Catch to determine what the error message is.
My question is: what would lead to $Error $Null inside Catch ?
powershell error-handling
Jnk
source share