Right, I meant derive. Sorry. I was just trying to understand the best
way to deal with errors in Clojure. I thought what you were saying was
that we could derive exceptions from RuntimeException and they
wouldn't get wrapped. It seems to negate the value of try/catch if
every exception (including RuntimeExceptions) are wrapped in
RuntimeExceptions that have to be unwrapped to find the true cause. I
have noticed in the REPL in emacs I have to usually drill down three
or four levels to find the true cause (and file and line no) of an
exception.

However, since I'm relatively new here, I did a search in the archive,
and turned up this message, which seems to layout a better, more
Clojureish way to handle errors using dynamic vars bound to 'recovery'
functions.

http://groups.google.com/group/clojure/msg/842e8bb058015282


Paul

On Fri, Oct 24, 2008 at 8:18 AM, Rich Hickey <[EMAIL PROTECTED]> wrote:
>
>
>
> On Oct 24, 7:46 am, "Paul Stadig" <[EMAIL PROTECTED]> wrote:
>> So the moral of the story (in terms of idiomatic clojure) is to
>> declare RuntimeExceptions instead of Exceptions (if you need to
>> declare an exception)? Or is there a better way to handle errors?
>>
>
> You don't declare exceptions in Clojure. If you mean derive from
> RuntimeException, that won't help, as at present most wrapping
> contexts just catch any Exception (which will catch RuntimeExceptions)
> and throw wrapped in a new RuntimeException. I recommend you try to
> use an existing Exception type when possible (there are too many
> already), and derive from Exception otherwise.
>
> The real issue is on the handling side. In general, I think unless you
> are directly calling something that declares specific exceptions, you
> need to catch Exception then see what you've got, including examining
> the cause. You should presume that all generic plumbing, i.e. most of
> Clojure, might throw Exceptions, sometimes wrapping others.
>
> Rich
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
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