Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > catching all errors

Reply
Thread Tools

catching all errors

 
 
=?Utf-8?B?cm9kY2hhcg==?=
Guest
Posts: n/a
 
      11-19-2006
hey all,
is there a way to catch all errors for my webform without using the
global.asax page?
thanks,
rodchar
 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      11-19-2006
"rodchar" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...

> is there a way to catch all errors for my webform without using the
> global.asax page?


Other than surrounding all your code with try...catch, I don't think so...


 
Reply With Quote
 
 
 
 
Michael Nemtsev
Guest
Posts: n/a
 
      11-19-2006
Hello Mark,

BTW, u can handle your exceptions with System.Web.UI.Page.Error even

MR> "rodchar" <(E-Mail Removed)> wrote in message
MR> news(E-Mail Removed)...
MR>
>> is there a way to catch all errors for my webform without using the
>> global.asax page?
>>

MR> Other than surrounding all your code with try...catch, I don't think
MR> so...
MR>
---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche


 
Reply With Quote
 
Annie
Guest
Posts: n/a
 
      11-20-2006
Hi Michael,
Can you please explain what mean?
many thanks


"Michael Nemtsev" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) t.com...
> Hello Mark,
>
> BTW, u can handle your exceptions with System.Web.UI.Page.Error even
>
> MR> "rodchar" <(E-Mail Removed)> wrote in message
> MR> news(E-Mail Removed)...
> MR>
>>> is there a way to catch all errors for my webform without using the
>>> global.asax page?
>>>

> MR> Other than surrounding all your code with try...catch, I don't think
> MR> so...
> MR> ---
> WBR,
> Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour
>
> "At times one remains faithful to a cause only because its opponents do
> not cease to be insipid." (c) Friedrich Nietzsche
>
>



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      11-20-2006
"Annie" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> Can you please explain what mean?


http://msdn2.microsoft.com/en-us/lib...40(VS.80).aspx

Pay particular attention to the very first line of the article, which says:
"If possible, you should handle errors in Try/Catch blocks within your
code..."

That is the preferred method of error handling in .NET applications, but
Michael is correctly reminding me that it's not the *ONLY* way...

AAMOI, is anyone actually using Page_Error...?


 
Reply With Quote
 
Karl Seguin
Guest
Posts: n/a
 
      11-20-2006
That website is TOTALLY AND ABSOLUTELY WRONG. It _WILL_ get corrected during
the next major revision (or help me god...). Well over 90% of the time you
can't handle an actual exception..all you can do is clean up...in which case
you should be using try/finallys and "usings". Your logging code should be
centralized, and the best way to do this is with Global.asax's on error ..

Handling exceptions in global.asax is the CORRECT way to do things.

As was mentioned, you can also catch errors in the page. you can do this by
overriding the OnError method.

protected override void OnError(EventArgs e)
{
...
}

if you put this in a base class and have all your pages inherit from it,
you're good to go.

More on exception hanlding in .NET:
http://codebetter.com/blogs/karlsegu...05/142355.aspx

Karl
--
http://www.openmymind.net/
http://www.codebetter.com/


"Mark Rae" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Annie" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> Can you please explain what mean?

>
> http://msdn2.microsoft.com/en-us/lib...40(VS.80).aspx
>
> Pay particular attention to the very first line of the article, which
> says: "If possible, you should handle errors in Try/Catch blocks within
> your code..."
>
> That is the preferred method of error handling in .NET applications, but
> Michael is correctly reminding me that it's not the *ONLY* way...
>
> AAMOI, is anyone actually using Page_Error...?
>


 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      11-20-2006
"Karl Seguin" <(E-Mail Removed) > wrote in
message news:(E-Mail Removed)...

> That website is TOTALLY AND ABSOLUTELY WRONG. It _WILL_ get corrected
> during the next major revision (or help me god...).


Glad to hear it!

For the record, I wasn't actually recommending following its contents -
quite the reverse...

> Well over 90% of the time you can't handle an actual exception..all you
> can do is clean up...
> in which case you should be using try/finallys and "usings".


I couldn't agree more...

>Your logging code should be centralized, and the best way to do this is
>with Global.asax's on error ..


Again, totally agreed...


 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
why does catching errors that aren't thrown give syntax errors? yawnmoth Java 97 02-27-2009 12:07 AM
catching errors with XPathExpression darrel ASP .Net 0 09-28-2005 04:44 PM
Errors, errors, errors Mark Goldin ASP .Net 2 01-17-2004 08:05 PM
Catching Framework Errors TonyG ASP .Net 1 08-26-2003 06:52 PM
Catching ASP.NET errors Mikael Engdahl ASP .Net 3 08-15-2003 06:18 PM



Advertisments