By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,670 Members | 1,563 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,670 IT Pros & Developers. It's quick & easy.

Exception not showing stack

P: n/a
If I do a:

throw(new Exception("This is an error"));

This gets handled correctly, but there is no stack information here.

Why is that?

Thanks,

Tom
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
tshad wrote:
If I do a:

throw(new Exception("This is an error"));

This gets handled correctly, but there is no stack information here.

Why is that?
No idea. You didn't show the code that's supposed to handle the exception.
That's where you'd expect the stack information to show up, no?

One well-known caveat is that rethrowing an exception "the wrong way" will
destroy the stack. If you do this:

..
} catch (Exception e) {
throw e;
}

The original exception's call stack is trashed and the exception will
instead appear to originate from the catch block. The correct syntax is

..
} catch (Exception e) {
throw;
}

That is assuming that catching and rethrowing the exception is the right
thing to do in the first place, of course, which it isn't that often.

Other than that, you'll have to be more specific.

--
J.
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.