Problem in ASP.NET to throw an error and catch it in the global.asax
<p>In an aspx web page I'm doing this:</p>

<pre><code>Try

    Throw new IndexOutOfRangeException

Catch ex As Exception

    Dim myException As New bizException(ex)

    Throw myException

End Try
</code></pre>

<p>In the global.asax I'm doing this:</p>

<pre><code>Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)

    Dim myException As bizException = DirectCast(Server.GetLastError().GetBaseException(), bizException)


End Sub
</code></pre>

<p>An this error is occuring during the cast:</p>

<p>InvalidCastException:
Unable to cast object of type 'System.IndexOutOfRangeException' to type 'bizException'.</p>

<p>The GetLastError's type is IndexOutOfRangeException and not bizException... Why ?</p>
