have a cljs (node) app that invokes some non-trivial sci code, which in turn ends up calling out to (cljs) fns that were bound in the environment: A: app(nodejs) -> B: big-fuzzy-ball-of-sci-code (sci) -> C: app(nodejs) Something in C throws exception, which in turn bubbles up to A, leaving me wondering if there is any straightforward/kosher way of introspecting what the call-stack in B was at the time - obviously looking for the call stack in terms of the code being interpreted rather then SCI itself. any clean / kosher way to do such a thing?
the SCI exception contains information that can be turned into a stack trace
Example:
$ clj -M:cljs -m cljs.main -re node
ClojureScript 1.11.54
cljs.user=> (require '[sci.core :as sci])
nil
cljs.user=> (try (sci/eval-string "(assoc :a 1 2)") (catch js/Error e (->> (sci/stacktrace e) sci/format-stacktrace (run! println))))
clojure.core/assoc - <built-in>
user - <expr>:1:1
nilwas seeing that when the source was sci code, but not when in node code it called into. Also bothered to look and updated from 0.8.40 to 0.8.43 and seems different (better). I was previously looking at (ex-data) and was getting back nil when it was a JS execption (like IndexError), but this looks better. I think you exposed sci/stacktrace recently, no?
not sure when that was exposed, but it's been a while
btw, If I haven't said it to you before, thanks a ton for SCI and offspring. We use the hell out of it, and it's flying around doing its job in airplanes.
haha amazing! hope it won't cause any airplane crashes!
non flight critical systems
worst that could happen is somebody can't turn on a light, flush a toilet, or watch their apple-tv
:)