tag:blogger.com,1999:blog-10770855.post220758637591513836..comments2024-03-28T03:20:57.393-04:00Comments on The Little Calculist: Continuation marks in exceptionsDave Hermanhttp://www.blogger.com/profile/00405190527081772997noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-10770855.post-12133709863330515962009-05-15T17:37:00.000-04:002009-05-15T17:37:00.000-04:00> I think Java might have chosen something lik...> I think Java might have chosen something like a policy where an exception value saves its stack trace at the point where it's created<br /><br />Almost: it saves its stack trace at the point its <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Throwable.html#fillInStackTrace()" REL="nofollow">fillInStackTrace()</A> method is called.Pete Kirkhamhttps://www.blogger.com/profile/17321624014729731964noreply@blogger.comtag:blogger.com,1999:blog-10770855.post-1103104871932799042009-05-15T11:07:00.000-04:002009-05-15T11:07:00.000-04:00Actually, newer versions of Java (1.4 onwards) sup...Actually, newer versions of Java (1.4 onwards) support "chained exceptions": If you say<br /><br />try { ... }<br />catch (SomeException e) {<br /> OtherException e2 = new OtherException("it broke", e);<br /> throw e2;<br />}<br /><br /><br />then e2.getCause() will return e, and e2's stack trace will say "caused by:" at the end and print the non-redundant part of e's stack trace as well. Not as flexible as having raw access to continuation marks but good enough to handle the most likely use cases.Jacob Matthewshttps://www.blogger.com/profile/01440842967865877789noreply@blogger.com