Filtered exception handling

less than 1 minute read

_[Duncan](http://weblogs.asp.net/duncanma) points out a [little something extra](http://weblogs.asp.net/duncanma/posts/10518.aspx) 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](http://www.panopticoncentral.net/PermaLink.aspx/f4ebdd14-2db0-4e03-a862-aca3d305437e)] > >

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

Updated: