On Sun, May 22, 2011 at 6:09 PM, Jason Wolfe <ja...@w01fe.com> wrote: > Looks really awesome -- I've been waiting for this since I switched to > Clojure from CL! > > I played around with it a bit, and there are a couple issues that > prevent it from being usable out of the box for me. > > 1. The usual repl entry point is not used, and so, e.g., (set! *warn- > on-reflection* true) fails. > > 2. I could not figure out a way to browse exception chains. > Typically the "real" stack trace for an exception is reached by > repeatedly calling .getCause on the exception until the innermost > exception is reached, but right now I can't see how to access causes > in the swank-clj debugger. For example try: > > (defn foo [x] (map - x)) > (foo (for [x (range 10)] (if (= x 8) "foo" x))) > > to see a useless stack trace (in 1.2). I see a couple places in the > code that deal with causes, so maybe I'm just missing how to access > them?
Well, if the exception gets bound to *e, you can use this: (defn pcause ([] (pcause *e)) ([e] (if-let [c (.getCause e)] (recur c) e))) ... => (do-something quux mumble 42) #<Boom!> => (pcause) Exception java.lang.ArithmeticException: divide by zero at clojure.lang.Numbers.divide (Numbers.java:138) at com.mycompany.myproject.foo$hairy_calc.invoke (foo.clj:192) at ... etc. or something like it. If it's not getting bound to *e, the above pcause can still be useful with (defmacro pe [& body] `(try ~@body (catch Throwable t (pcause t)))) ... => (testing-somefn foo 3.141 xyzzy) #<Kablooey!> => (pe (testing-somefn foo 3.141 xyzzy)) Exception java.io.IOException: stream closed at java.io.FileInputStream.read (FileInputStream.java:177) at com.mycompany.myproject.bar$some-func.invoke (bar.clj:211) at ... etc. => (defn some-func ... (doall ... )) #'com.mycompany.myproject.bar/some-func => (pe (testing-somefn foo 3.141 xyzzy)) 42 => Of course, if the exception is being thrown in some other thread, such as in the evaluation of a pmap or future, all bets are off. Try temporarily not using the parallelizing construct. In case of failed Agents, obviously try (pcause (agent-error agnt)). -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- 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