473,385 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How do I catch unhandled exceptions

Hello,

One of my web sites seems to throw the occasional exception in a place
where I don't expect it. I know I should expect them anywhere, but just
supposing I've missed one, is there a way of having some sort of global
catch-all that will allow me to log the error and present the user with
some friendly message?

TIA

--
Alan Silver
(anything added below this line is nothing to do with me)
Mar 20 '06 #1
5 1042
The Global.asax has an event called Applictions.OnError, you retreive
the last exception by using Server.GetLastError and log that exception
in this event.

Mar 20 '06 #2
In article <11*********************@t31g2000cwb.googlegroups. com>,
tdavisjr <td******@gmail.com> writes
The Global.asax has an event called Applictions.OnError, you retreive
the last exception by using Server.GetLastError and log that exception
in this event.


Thanks very much.

--
Alan Silver
(anything added below this line is nothing to do with me)
Mar 20 '06 #3
In article <11*********************@t31g2000cwb.googlegroups. com>,
tdavisjr <td******@gmail.com> writes
The Global.asax has an event called Applictions.OnError, you retreive
the last exception by using Server.GetLastError and log that exception
in this event.


OK, I looked into this a bit more, and it seems I can't really get much
interesting information, such as what page generated the error and what
it was doing. The stack trace is very generic and doesn't really help me
at all.

Is there any way to get more info in this event? Even knowing which page
was being executed would be a start, but ideally I would like more than
that. TIA

--
Alan Silver
(anything added below this line is nothing to do with me)
Mar 22 '06 #4
Oh. On the Exception object look at the InnerException and print the
stack trace for that. It will give detailed information. I forgot to
mention this.

Mar 22 '06 #5
In article <11**********************@z34g2000cwc.googlegroups .com>,
tdavisjr <td******@gmail.com> writes
Oh. On the Exception object look at the InnerException and print the
stack trace for that. It will give detailed information. I forgot to
mention this.


Thanks, I'll see if that is any more enlightening ;-)

--
Alan Silver
(anything added below this line is nothing to do with me)
Mar 23 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: DraguVaso | last post by:
Hi, In my application, on some given actions while debugging in Visual Studio, I suddenly get a "System.ComponentModel.Win32Exception was unhandled" Message="Error creating window handle."...
5
by: Simon Johnson | last post by:
Recently, a thread appeared which asked how to create a "catch all" method for when an exception occurs within a program. The solution given only works for Windows Forms applications, as far as i...
5
by: David | last post by:
I am having a bit of a problem with catching an exception within a thread. Here is the scenario: I have a Windows Form. I create a new thread. This new thread calls a method in another DLL...
7
by: Arjen | last post by:
Hi, I'm doing this: try { try { } catch(Exception ex){ throw;
2
by: Ralph Krausse | last post by:
I created a try/catch/finally but when an expection is thrown, the catch does not handle it... (I know this code is wrong, I want to force the error for this example) try { DataSet ds = new...
6
by: Martin Ortiz | last post by:
Which is best approach? Should Try + Catch be used to only deal with "catastrophic" events (like divide by zero, non-existant file, etc...etc...) Or should Try + Catch be used IN PLACE of...
5
by: Simon Tamman {Uchiha Jax} | last post by:
Now this is bugging me. I just released software for a client and they have reported an unhandled stack overflow exception. My first concern is that the entirity of the UI and any threaded...
4
by: bad_boyu | last post by:
Hello, I have the following code: try { Salarii.Editors.AngajatiNewFrm _angNewFrm = new Salarii.Editors.AngajatiNewFrm(); _angNewFrm.Connection = this.Connection; _angNewFrm.ShowInTaskbar =...
17
by: Zytan | last post by:
I am using: Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); But, my function is not run when an exception is thrown on another...
6
by: rhaazy | last post by:
I am looking for some feedback on using try catch statements. Usually when I start a project I use them for everything, but stop using them as often after the "meat n' potatos" of the project is...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.