Filtered exception handling

less than 1 minute read

_[Duncan]( points out a [little something extra]( that VB.NET's Try...Catch syntax supports. It's something the underlying IL supports and it seems useful, so we figured, why not? A use that comes to mind is when dealing with COMExceptions:_ > > > Try
</br> ' Do some COM interop
</br>Catch ex As COMException When ex.ErrorCode = &H80043919
</br> ' Handle this specific error
</br>End Try > > > _Nothing fancy, just a little something extra. An interesting thing to note is that the CLR doesn't actually support specifying both a type filter (i.e. ex As COMException) and a filter expression (i.e. Where ex.ErrorCode = &H800043919), so the above Catch clause is a filter expression that checks both the type and the value together. It doesn't use a type filter. I was never really clear why the CLR did it that way, but it's not a big deal either way._ [[ Panopticon Central](] > >

Not sure how useful this will be, but you do learn something every day!