Hi,

On Aug 27, 5:47 am, Tim Snyder <[email protected]> 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 [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to