Skip to content

Instantly share code, notes, and snippets.

@Gonzih
Created February 10, 2015 16:17
Show Gist options
  • Save Gonzih/399cff0bd5dd5c558192 to your computer and use it in GitHub Desktop.
Save Gonzih/399cff0bd5dd5c558192 to your computer and use it in GitHub Desktop.
Clsj stacktraces
(require 'cljs.repl)
(in-ns 'cljs.repl)
(def st [;"TypeError: Object [object Object] has no method 'tc'\n"
" at Function.a (<eval>:10008:68)\n"
" at Function.b (<eval>:10008:161)\n"
" at Object.init_state (<eval>:10090:59)\n"
" at <eval>:1:36"])
(def f "public/javascripts/server-side.js")
(defn parse-stack-trace [s]
(let [[_ fn-name line column] (re-find #"\s*at\s(.*)\s\(?<eval>:([0-9]*):([0-9]*)\)?.*" s)]
{:file f
:function fn-name
:line line
:column column}))
(read-source-map f)
(ns-info f)
(mapped-line-and-column (read-source-map f) 10008 68)
(mapped-line-and-column (read-source-map f) 10008 161)
(cljrepl/demunge "Function.a")
(js-src->cljs-src e)
(print-mapped-stacktrace (map parse-stack-trace st))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment