On Thu, Aug 27, 2009 at 8:10 PM, Tim Snyder<tsnyder...@gmail.com> wrote:
>
> Well, I can see that LazySeq does indeed catch and wrap all Exceptions
> in a RuntimeException.  I also think I can work around it, but I'd
> like to know why this was done?
>
> Was it necessary given the checked vs. unchecked exception system of
> Java?
>

Yes.

Rich

> Is it because the exception generated by a lazy sequence may no longer
> be within the dynamic confines of the 'try' in which it was called and
> thus should be considered a runtime exception?
>
> Tim Snyder 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to