multi-exception cathing

bzbiz

Freshman
Joined
Mar 17, 2003
Messages
34
Location
Emilia - Italy
Hi folks!

How can i catch different kind of exception?

explain:

try
.......................
......................
catch ex as exception | ex2 as system.someKind.Exception

end try

it's possible?

Thanx in advance

ByeZ
BiZ
 
You can have many catch statements in your try, it can be used for different exceptions like you said.
Visual Basic:
try
.......................
...................... 
catch ex as exception

catch ex2 as system.someKind.Exception

end try
 
be careful with the order though - I beleive they are checked in turn and as all exceptions derive from System.Exception putting that first will catch every error and subsequent catch statments will be ignored.

e.g.

Visual Basic:
try 
    'something iffy here
catch ex as SpecificException
    'handle
catch ex as exception    'Default handler

end try
 
Back
Top