473,394 Members | 1,752 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,394 software developers and data experts.

e.InnerException.Message

I am trying to understand the uses for the the InnerException method of an
Exception object.

Looking at the documentation, I have summized this about using the
InnerException method....
If you have a method which can cause and exception, but you really do not
want to deal with the exception in that method, but you need/want to
provide some "details" of the circumstances of the error, is this when you
would catch the exception in that method, provide the details, and then
generate another exception passing along those details? Then the exception
woul go up the chain until some procedure caught the exception and then
would deal with it all the while have all the appropriate infomation to
deal with it?

Is this accurate?

What is not particular clear to me is how I would add value to this.
Suppose I wanted the "error message text" to be something like "Procedure
failed in .... The reason was.....". In order to do this I would have to
create an instance of my own error object and set the message accordingly?


System.Exception(e.InnerException.Message, e.InnerException)

Thanks In Advance for your assistance!!!!!!
Nov 15 '05 #1
2 6338
The advantage of this to me is to be able to pass a 'stack' of errors that
occured all the way up to my user interface and/or tracing class.

If you have a class that accesses a database and throws an error, you could
catch it, and then throw an exception that you create adding the caught
exception as the InnerException paramter. You could again catch that error
from the calling procedure and throw another error with the previous error
as it's InnerExcpeption paramter.

Once you are at a point where you display or record the error, you can use a
recursive method to record the error, check to see if there is an
InnerException, and if so call the same method to record that error and
check for another until you've reached the original error.

I hope I didn't make that more confusing than it is! :-)

-Darrin
"Jim Heavey" <Ji*******@nospam.com> wrote in message
news:Xn*********************************@207.46.24 8.16...
I am trying to understand the uses for the the InnerException method of an
Exception object.

Looking at the documentation, I have summized this about using the
InnerException method....
If you have a method which can cause and exception, but you really do not
want to deal with the exception in that method, but you need/want to
provide some "details" of the circumstances of the error, is this when you
would catch the exception in that method, provide the details, and then
generate another exception passing along those details? Then the exception woul go up the chain until some procedure caught the exception and then
would deal with it all the while have all the appropriate infomation to
deal with it?

Is this accurate?

What is not particular clear to me is how I would add value to this.
Suppose I wanted the "error message text" to be something like "Procedure
failed in .... The reason was.....". In order to do this I would have to
create an instance of my own error object and set the message accordingly?


System.Exception(e.InnerException.Message, e.InnerException)

Thanks In Advance for your assistance!!!!!!

Nov 15 '05 #2
"Jim Heavey" <Ji*******@nospam.com> wrote in message
news:Xn*********************************@207.46.24 8.16...
I am trying to understand the uses for the the InnerException method of an
Exception object.
You may have a couple reasons to use this. In your application you maybe
have designed it so that you always return "your" exception to all of your
consumers. You may have extra info that you include with all of "your"
exceptions. The InnerException is a place where you can store the original
exception that occurred. Second, you may have some kind of interpretation
of what happened and would like to return that interpretation to the
consumer, rather than the sometimes cryptic message that may come from the
deeper routine. For example, an Invalid Operation exception may be thrown
from some routine, but you know it may be just because your out of disk
space (or somesuch). You could provide the user friendly interpretation,
while still including the original exception info in the InnerException.
What is not particular clear to me is how I would add value to this.
Suppose I wanted the "error message text" to be something like "Procedure
failed in .... The reason was.....". In order to do this I would have to
create an instance of my own error object and set the message accordingly?


Derive your own exception class from System.Exception, or whichever FCL
exception class is most appropriate for you.

-- Alan
Nov 15 '05 #3

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

Similar topics

2
by: 2G | last post by:
Hi, I'm having some problems creating an instance of the dataset I compile in memory and I don't know why. I what to do this to Invoke WriteXmlSchema or GetSchemaSerializable so I could save...
8
by: Brian Keating EI9FXB | last post by:
Would I be correct in saying that the only way to get a user message into a Windows form would be to use P/Invoke with Message? Of is there some part of the .NET API that I am totally un aware...
10
by: ahager via DotNetMonster.com | last post by:
I am receiving this messaage in a console application I wrote, I am authenticating, and my network admin swears their is nothing wrong with the smtp server. Any ideas? public void Mail_update()...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
2
by: Microsoft News | last post by:
What I have is a message box that pops up. It is another browser window. The code is a general function that you pass message, title and a key to. The box works great except, that if you are on a...
2
by: Thomas I. | last post by:
I "occastionally" receive this error message when sending e-mail through the code below. It doesn't happen every time, but perhaps 10-30% of the time, I receive this exception message. ...
1
by: fripper | last post by:
I have a VB program that I created in VB .Net 2003 that I am trying to get running in VB 2005 ... LunarLander. The upgrade wizard tells me about a few problems that I have fixed but when I try to...
4
by: asanford | last post by:
http://msdn2.microsoft.com/en-us/library/ds492xtk.aspx Is this the following excerpt from the above page incorrect, or is there a bug in the .net 2.0 implementation? Or perhaps I have something...
1
by: KitKat | last post by:
Why am I getting this: An error occurred creating the form. See Exception.InnerException for details. The error is: Could not find any resources appropriate for the specified culture or the...
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: 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
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...

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.