471,356 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Exception not showing stack

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
1 1313
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.

Similar topics

4 posts views Thread by Barry Mossman | last post: by
13 posts views Thread by tolisss | last post: by
6 posts views Thread by perspolis | last post: by
132 posts views Thread by Zorro | last post: by
3 posts views Thread by Dave Anson | last post: by

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.