473,397 Members | 2,056 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,397 software developers and data experts.

System Exception

Is there a way to get to the last exception in .Net from outside a catch
block? I've inherited someone else's ASP.Net app that's having problems. He
is calling a method to log his errors but is only passing his custom error
messages so there is no way to know what is really happening. What I would
like to do is to access the last exception that occurred from the LogError()
function rather than have to modify all of the places that it is being called
to pass extra information to it.

Is there anything in .Net that provides access to the last exception data...
Message, StackTrace, etc?

Thanks,
Todd
Nov 19 '05 #1
6 1259
check out the Application_Error event handler in the global.asax file

http://msdn.microsoft.com/library/de...sp08232001.asp
--
HTH

Ollie Riches
http://www.phoneanalyser.net
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.

"Todd Bright" <To********@discussions.microsoft.com> wrote in message
news:AA**********************************@microsof t.com...
Is there a way to get to the last exception in .Net from outside a catch
block? I've inherited someone else's ASP.Net app that's having problems.
He
is calling a method to log his errors but is only passing his custom error
messages so there is no way to know what is really happening. What I
would
like to do is to access the last exception that occurred from the
LogError()
function rather than have to modify all of the places that it is being
called
to pass extra information to it.

Is there anything in .Net that provides access to the last exception
data...
Message, StackTrace, etc?

Thanks,
Todd

Nov 19 '05 #2
I think the capability to have these type of event handlers is really useful.
However, these errors are already being trapped. The error trap is calling
a LogError() function passing it a string. Rather than go to every call to
LogError() and modify the string being passed, I would like to be able to get
to the last exception object from within the LogError() function itself.
That way I'll only need to make a code change in one place.
"Ollie" wrote:
check out the Application_Error event handler in the global.asax file

http://msdn.microsoft.com/library/de...sp08232001.asp
--
HTH

Ollie Riches
http://www.phoneanalyser.net
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.

"Todd Bright" <To********@discussions.microsoft.com> wrote in message
news:AA**********************************@microsof t.com...
Is there a way to get to the last exception in .Net from outside a catch
block? I've inherited someone else's ASP.Net app that's having problems.
He
is calling a method to log his errors but is only passing his custom error
messages so there is no way to know what is really happening. What I
would
like to do is to access the last exception that occurred from the
LogError()
function rather than have to modify all of the places that it is being
called
to pass extra information to it.

Is there anything in .Net that provides access to the last exception
data...
Message, StackTrace, etc?

Thanks,
Todd


Nov 19 '05 #3
You can also look at Server.GetLastError. I'm not clear on what your
application is doing, but this property may work for you.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 16 Feb 2005 13:53:02 -0800, "Todd Bright"
<To********@discussions.microsoft.com> wrote:
I think the capability to have these type of event handlers is really useful.
However, these errors are already being trapped. The error trap is calling
a LogError() function passing it a string. Rather than go to every call to
LogError() and modify the string being passed, I would like to be able to get
to the last exception object from within the LogError() function itself.
That way I'll only need to make a code change in one place.
"Ollie" wrote:
check out the Application_Error event handler in the global.asax file

http://msdn.microsoft.com/library/de...sp08232001.asp
--
HTH

Ollie Riches
http://www.phoneanalyser.net
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.

"Todd Bright" <To********@discussions.microsoft.com> wrote in message
news:AA**********************************@microsof t.com...
> Is there a way to get to the last exception in .Net from outside a catch
> block? I've inherited someone else's ASP.Net app that's having problems.
> He
> is calling a method to log his errors but is only passing his custom error
> messages so there is no way to know what is really happening. What I
> would
> like to do is to access the last exception that occurred from the
> LogError()
> function rather than have to modify all of the places that it is being
> called
> to pass extra information to it.
>
> Is there anything in .Net that provides access to the last exception
> data...
> Message, StackTrace, etc?
>
> Thanks,
> Todd



Nov 19 '05 #4
I tried this but GetLastError() returns NULL, probably because I'm already
trapping the error. All the documentation says that it's used to get the
last UNTRAPPED error. Looks like I'm down to modifying each call.
"Scott Allen" wrote:
You can also look at Server.GetLastError. I'm not clear on what your
application is doing, but this property may work for you.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 16 Feb 2005 13:53:02 -0800, "Todd Bright"
<To********@discussions.microsoft.com> wrote:
I think the capability to have these type of event handlers is really useful.
However, these errors are already being trapped. The error trap is calling
a LogError() function passing it a string. Rather than go to every call to
LogError() and modify the string being passed, I would like to be able to get
to the last exception object from within the LogError() function itself.
That way I'll only need to make a code change in one place.
"Ollie" wrote:
check out the Application_Error event handler in the global.asax file

http://msdn.microsoft.com/library/de...sp08232001.asp
--
HTH

Ollie Riches
http://www.phoneanalyser.net
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.

"Todd Bright" <To********@discussions.microsoft.com> wrote in message
news:AA**********************************@microsof t.com...
> Is there a way to get to the last exception in .Net from outside a catch
> block? I've inherited someone else's ASP.Net app that's having problems.
> He
> is calling a method to log his errors but is only passing his custom error
> messages so there is no way to know what is really happening. What I
> would
> like to do is to access the last exception that occurred from the
> LogError()
> function rather than have to modify all of the places that it is being
> called
> to pass extra information to it.
>
> Is there anything in .Net that provides access to the last exception
> data...
> Message, StackTrace, etc?
>
> Thanks,
> Todd


Nov 19 '05 #5
Yes, that's unfortunate. Looks like operation "Search & Replace" is in
effect :)

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 17 Feb 2005 06:35:09 -0800, "Todd Bright"
<To********@discussions.microsoft.com> wrote:
I tried this but GetLastError() returns NULL, probably because I'm already
trapping the error. All the documentation says that it's used to get the
last UNTRAPPED error. Looks like I'm down to modifying each call.


Nov 19 '05 #6
Thanks for the info anyhow.

"Scott Allen" wrote:
Yes, that's unfortunate. Looks like operation "Search & Replace" is in
effect :)

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 17 Feb 2005 06:35:09 -0800, "Todd Bright"
<To********@discussions.microsoft.com> wrote:
I tried this but GetLastError() returns NULL, probably because I'm already
trapping the error. All the documentation says that it's used to get the
last UNTRAPPED error. Looks like I'm down to modifying each call.


Nov 19 '05 #7

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

Similar topics

1
by: Matthias Ludwig | last post by:
I'm trying to create a directory on the web server with a vb.net code: .... Dim dirName As String = "w:\filepath\images" If Not Directory.Exists(dirName) Then...
1
by: Rafael | last post by:
Hi, I hope I can find some help for this problem IDE: Visual Studio.NET 2003 Developer Editio Language: C# Problem: "An unhandled exception of type 'System.NullReferenceException' occurred in...
2
by: Paul Gronka | last post by:
I've got a VB.NET windows application (written in VS .NET 2003) that makes a call to WMI for retrieving the MAC Address from the client's PC. It works on 4 out of the 5 PC's tested so far. All...
5
by: Vitling | last post by:
For no apparent reason, a NullReference exception is thrown in system.dll (System.Net.Sockets.OverlappedAsyncResult.CompletionPortCallback). Since I only get a disassembly from Visual Studio, it...
4
by: Bhavya Shah | last post by:
Hello, I am facing a very strange problem in my application. I have a form on which I select a path. I open the FolderBrowserDialog for path selection. Once the path is selected I press a button...
0
by: John.Luckowsky | last post by:
Hello all, I've moved my old ASP1.1 with WSE2.0 SP3 to ASP2.0 and have found strange error which raises spontaneously. Here is the stack trace: System.InvalidOperationException Message: The...
2
by: koredump | last post by:
Hi all, I have a windows app that makes some asyc calls to my webservice (WSE 3.0 with MTOM). exception gets thrown in the client win app. This exception is being thrown on another thread by a...
5
by: scheidel21 | last post by:
I am writting a DB front end in VB.NET 2003 I have a form that displays employee information it has a dataset loaded from the DB that also includes tables for lookup in some comboboxes that are...
2
by: pedrito | last post by:
I've got an app that downloads from several concurrent threads. Occasionally, I get an expcetion trying to read the HttpWebResponse stream... Sorry, the code isn't short, but I figured best to...
2
by: satnamsarai | last post by:
Using System.Net.Mail: Sometimes I get error 'failure sending mail. Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.' Not sure how...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.