In my communication layer I have a need to be able to catch ANY javascript exception, log it down and proceed as I normally would do. Current syntax for catching exceptions in Clojurescript dictates that I need to specify the type of the exception being caught.
I tried to use nil, js/Error, js/object in the catch form and it doesn't catch ANY javascript exception (which can have string as the type of the object).
I would appreciate any hints how this can be done natively in Clojurescript.
It looks like js/Object catches them all (tested on https://himera.herokuapp.com):
One thing to watch out for is lazy sequences. If an error is thrown in a lazy sequence that part of the code might not be executed until after you've exited the try function. For example:
In that last case, map creates a lazy sequence and the try function returns it. Then, when the repl tries to print the sequence to the console, it's evaluated and the error gets thrown outside of the try expression.
I think I've just found the solution in this link https://groups.google.com/forum/#!topic/clojure/QHaTwjD4zzU
I copy the contents here: This solution was published by Herwig Hochleitner
And here is my implementation working now:
I hope it helps you
Juan
I found another possible answer in David Nolen "Light Table ClojureScript Tutorial"