Apache's commons-lang library has a utility class that has a decent amount of functionality for dissecting exception stacks/traces (getRootCause() maybe what you want): http://commons.apache.org/lang/api/org/apache/commons/lang/exception/ExceptionUtils.html On Thu, Aug 27, 2009 at 10:03 AM, Tim Snyder <tsnyder...@gmail.com> wrote:
> > Thanks for the replies. I'll have a look at the impl. of LazySeq > tonight and see if that helps. It sounds like it shouldn't be a > problem to work around though. Is there somewhere I can read that > gives an explanation or information about why this is done? > > On Aug 27, 9:33 am, Meikel Brandmeyer <m...@kotka.de> wrote: > > Hi, > > > > On Aug 27, 5:47 am, Tim Snyder <tsnyder...@gmail.com> wrote: > > > > > > > > > > > > > I'm trying to understand how laziness affects exception handling. I > > > keep finding my exceptions wrapped in RuntimeExceptions. > > > > > If I have code that just throws an exception, I get what I'd expect: > > > (throw (Exception. "Plain Exception")) --> > > > Plain Exception > > > [thrown class java.lang.Exception] > > > > > On the other hand if I make the exception lazy, it is always wrapped > > > in a RuntimeException: > > > (lazy-seq > > > [(throw (Exception. > > > "NotPlainException"))]) --> > > > java.lang.Exception: NotPlainException > > > [Thrown class java.lang.RuntimeException] > > > > > This of course makes it harder to deal with the exceptions. I've > > > looked through the stack traces but can't see any solution. Is this > > > due to the Java difference between checked and unchecked exceptions? > > > Is there a reasonable way to work around it? Doall has no effect. > > > > You can travel down the exception chain by means of .getCause. Do that > > until you find your Exception or maybe until the cause is not a > > RuntimeException anymore. If you didn't find something of concern > > rethrow the original exception. Does that make sense? > > > > Sincerely > > Meikel > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---