|
-
May 17th, 2005, 02:14 AM
#1
GetBaseException and InnerException
In my Global.asax file, I'm working with the exceptions like this:
VB Code:
Dim context As System.Web.HttpContext = HttpContext.Current
Dim ex As System.Exception = context.Server.GetLastError.GetBaseException()
Now the question is very simple:
What is the difference between GetBaseException() and InnerException, and which one should I be working with?
-
May 20th, 2005, 04:11 PM
#2
I wonder how many charact
Re: GetBaseException and InnerException
BaseException
---throws
------someOtherException
------someOtherException.innerException = (baseException)
Basically, the baseexception is the exception that caused all the other exceptions to occur. If the a filenotfoundException occurs, and then throws a someOtherException... the innerException of the someOtherException will return the baseexception.
Which seems rather silly, until you realize there could be many exceptions thrown because of one underlying exception (which is normal).
So if you had one exception that caused 15 other exceptions to occur (bubble), the 15th exception would have to call the innerException property to get a reference to the 14th exception, which would then have to call its innerException property to get a reference to the 13th exception...so forth. As you see, this would be real pain to tranverse anytime you wanted the underlying base exception of them all... which is why the class has the GetBaseException() method that transverses those layers for you to retrieve the underlying 1st exception that started it all.
-
May 21st, 2005, 02:39 AM
#3
Re: GetBaseException and InnerException
Excellent explanation, thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|