title: $Error variable is $Null but $_ contains error in Catch
body: <p>I have PS module that contains a number of scripts for individual functions.  There is also a "library" script with a number of helper functions that get called by the functions used in the module.</p>
  
  <p>Let's call the outer function <code>ReadWeb</code>, and it uses a helper function <code>ParseXML</code>.</p>
  
  <p>I encountered an issue this week with error handling in the inner helper <code>ParseXML</code> function.  That function contains a try/catch, and in the catch I interrogate:</p>
  
  <p><code>$Error[0].Exception.InnerException.Message</code></p>
  
  <p>...in order to pass the error back to the outer scope as a variable and determine if <code>ParseXML</code> worked.</p>
  
  <p>For a particular case, I was getting an indexing error when I called <code>ReadWeb</code>.  The root cause turned out to be the <code>$Error</code> object in the <code>Catch</code> block in <code>ParseXML</code> was coming back <code>$Null</code>.  </p>
  
  <p>I changed the error handling to check for a <code>$Error -eq $Null</code> and if it is, use <code>$_</code> in the <code>Catch</code> to determine what the error message is.</p>
  
  <p>My question is: <strong>what would cause <code>$Error</code> to be <code>$null</code> inside the <code>Catch</code>?</strong></p>