Error handling

T

tom c

Is there something in Exception that will give me a simple error
number, so that I can write code for certain types of errors.

For example if "file not found" is error number 123 I could just write
code for error 123. I used to do that in VB, but I can't find the
error number in ASP.Net.
 
S

sloan

You catch "more specific exceptions" .. and you should probably abandon the
number system used in vb6.

Try


Catch ioe as IOException
''do something with ioe
Catch aex as ArgumentException
''do something with aex
Catch ex as Exception
'do something with ex
Finally

End Try


see http://www.vbdotnetheaven.com/Code/Apr2003/009.asp for more info.
 
T

tom c

Thanks Sloan, but I still need some number that identifies the specific
exception so that I can compare two exceptions to each other and write
specific code for specific exceptions.

I know I could write logic

if left(exception.message,20) = "Could not find file" then
do something
end if

But if would be so much easier if I could write:

If exception.property = 123 then
do something
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top