Skip to content

Instantly share code, notes, and snippets.

@mfikes
Last active August 29, 2015 14:17
Show Gist options
  • Save mfikes/d3cd31cddeecb918677e to your computer and use it in GitHub Desktop.
Save mfikes/d3cd31cddeecb918677e to your computer and use it in GitHub Desktop.
stack trace names

Let's say we do (ffirst 1) in Ambly.

This results in

Error: 1 is not ISeqable
   cljs$core$seq (.../cljs/core.cljs:951:13)
   cljs$core$first (.../cljs/core.cljs:960:7)
   cljs$core$ffirst (.../cljs/core.cljs:1393:3)
   (NO_SOURCE_FILE)

For the very top of the trace, the JavaScript is at line 4667 column 17:

throw (new Error([cljs.core.str(coll),cljs.core.str(" is not ISeqable")].join('')));

which has :name "js/Error" in the source map info (which we aren't interested in), but this is where we extract that we are at line 951 (1-based) in the original source:

{0 [{:line 935, :col 4, :source "core.cljs"} {:line 950, :col 12, :source "core.cljs"}], 6 [{:line 950, :col 19, :source "core.cljs"}], 11 [{:name "js/Error", :line 950, :col 19, :source "core.cljs"}], 17 [{:line 950, :col 30, :source "core.cljs"}], 32 [{:name "coll", :line 950, :col 35, :source "core.cljs"}], 52 [{:line 950, :col 30, :source "core.cljs"}]}

Next down we are at 4697 22, which contains the seq call

var s = cljs.core.seq(coll);

which has the desired :name "cljs.core/seq" in the source map info:

{0 [{:line 959, :col 6, :source "core.cljs"}], 4 [{:name "s", :line 959, :col 12, :source "core.cljs"}], 8 [{:line 959, :col 14, :source "core.cljs"} {:name "cljs.core/seq", :line 959, :col 15, :source "core.cljs"}], 22 [{:name "coll", :line 959, :col 19, :source "core.cljs"}]}

Next down we are at 5774 39, which contains the first call:

return cljs.core.first(cljs.core.first(coll));

which has the desired :name "cljs.core/first" in the source map info:

{0 [{:line 1389, :col 0, :source "core.cljs"} {:line 1392, :col 2, :source "core.cljs"}], 7 [{:name "cljs.core/first", :line 1392, :col 3, :source "core.cljs"}], 23 [{:line 1392, :col 9, :source "core.cljs"} {:name "cljs.core/first", :line 1392, :col 10, :source "core.cljs"}], 39 [{:name "coll", :line 1392, :col 16, :source "core.cljs"}]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment