|
-
Jan 18th, 2007, 07:42 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] SELECT CASE on Exceptions
I have an exception object.
I want to do a select case to perform certain activities in cases when the exception is of a specific type.
So how would I structure such a SELECT CASE block?
For instance:
VB Code:
Select Case ex
Case System.StackOverflowException
Case System.ObjectDisposedException
End Select
Obviously, the above doesn't work but you get the idea...
Last edited by simonm; Jan 19th, 2007 at 04:47 AM.
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Jan 18th, 2007, 07:47 AM
#2
Re: SELECT CASE on Exceptions
Build your try block to catch all the different kind of exceptions.
VB Code:
Try
catch exSO as StackOverflowException
'overflow occured
catch exOD as ObjectDisposedException
'etc etc
End Try
now youll know what exception occured.
Last edited by Atheist; Jan 18th, 2007 at 07:51 AM.
-
Jan 18th, 2007, 08:06 AM
#3
Thread Starter
Fanatic Member
Re: SELECT CASE on Exceptions
No, I can't use that method because the exception is passed into another procedure.
In other words, the place where I am interrogating the exception is not where the exception occurred (nor can that be helped).
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Jan 18th, 2007, 08:17 AM
#4
Re: SELECT CASE on Exceptions
What you're asking for is not possible because the Select Case syntax doesn't support it. You can do this:
VB Code:
Select Case True
Case TypeOf ex Is StackOverflowException
Case TypeOf ex Is ObjectDisposedException
End Select
but that gains you nothing over regular If...ElseIf statements.
-
Jan 19th, 2007, 04:47 AM
#5
Thread Starter
Fanatic Member
Re: SELECT CASE on Exceptions
Great thanks. That's just what I want.
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|