![]() |
|
|
|
#1 |
|
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. tom c |
|
|
|
|
#2 |
|
Posts: n/a
|
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. "tom c" <> wrote in message news: oups.com... > 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. > sloan |
|
|
|
#3 |
|
Posts: n/a
|
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 sloan wrote: > 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. > > > > "tom c" <> wrote in message > news: oups.com... > > 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. > > tom c |
|
|
|
#4 |
|
Posts: n/a
|
Uh, isn't that what's Sloan's code is doing?
In .NET you can check for specific exceptions which should be clearly identified by the specific APIs that you're calling. +++ Rick --- -- Rick Strahl West Wind Technologies http://www.west-wind.com/weblog http://www.west-wind.com/wwThreads/ "tom c" <> wrote in message news: ups.com... > 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 > > > > sloan wrote: >> 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. >> >> >> >> "tom c" <> wrote in message >> news: oups.com... >> > 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. >> > > Rick Strahl |
|