Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Error handling

 
Thread Tools Search this Thread
Old 07-09-2006, 01:39 AM   #1
Default Error handling


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
  Reply With Quote
Old 07-09-2006, 01:53 AM   #2
sloan
 
Posts: n/a
Default Re: Error handling

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
  Reply With Quote
Old 07-09-2006, 03:12 AM   #3
tom c
 
Posts: n/a
Default Re: Error handling
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
  Reply With Quote
Old 07-09-2006, 06:11 AM   #4
Rick Strahl
 
Posts: n/a
Default Re: Error handling
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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46