1

I've just been scratching my hairs for a long time with an error I couldn't find. It turned out to be an arity exception but apparently because it happened on the EDT I couldn't "see" it. It didn't show in the "lein run" terminal when run from a terminal and it didn't show in any Emacs buffer when run from Emacs.

After a very long time I ended up doing this:

(try (function-call-with-arity-error ...) (catch Exception e (println e)

and, at last, thanks to this, I got to see this printed:

#<ArityException clojure.lang.ArityException: wrong number of args passed to...

and hence I've been able to find my error.

And if I do this:

(do 
   (println "trying...")
   (arity-error-here-on-purpose) ; this ones throws the arity error
   (println "done")
)

Then the terminal prints "trying..." but never gets to "done...".

I tried setting a default uncaught exception handler: the exception isn't getting caught. It's as if the program or the EDT was "stuck" after the arity exception (without printing anything anywhere).

How am I suppose to deal with this the next time? Because I couldn't see any message anywhere it took me a really long time to find. Once again: nothing in the 'lein run' terminal and nothing in any Emacs buffer.

Should I create a function that wraps calls that should happen on the EDT inside try / catch manually and that then logs/println the exception?

Also note that this is in a relatively "long" Clojure app: 1000 lines of code, so I can't paste it here and I couldn't reproduce that behavior in a short example (but it happens consistently in my app).

1

1 Answer 1

0

You can register an uncaught exception handler with a Thread so you don't have to wrap all the calls that can occur on the EDT.

Try registering one with the EDT and seeing if this gives you the desired behavior.

1
  • thanks for helping me with this. I just tried and it doesn't work: it's as if the EDT was locked right after the arity exception and the uncaught exception handler ain't catching the exception (I did try with other exceptions, from other threads, and the handler is catching them fine). Mar 26, 2013 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.