Skip to content

Commit

Permalink
CLJS-1388: Stacktrace element handling for :output-dir w/o file/line/…
Browse files Browse the repository at this point in the history
…column
  • Loading branch information
swannodette committed Aug 3, 2015
1 parent d946a58 commit 49f3ea9
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions src/main/cljs/cljs/stacktrace.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,25 @@
[repl-env st err opts] st)

(defn parse-file-line-column [flc]
(let [xs (string/split flc #":")
[pre [line column]]
(reduce
(fn [[pre post] [x i]]
(if (<= i 2)
[pre (conj post x)]
[(conj pre x) post]))
[[] []] (map vector xs (range (count xs) 0 -1)))
file (string/join ":" pre)]
[(cond-> file
(starts-with? file "(") (string/replace "(" ""))
(parse-int
(cond-> line
(ends-with? line ")") (string/replace ")" "")))
(parse-int
(cond-> column
(ends-with? column ")") (string/replace ")" "")))]))
(if-not (re-find #":" flc)
[flc nil nil]
(let [xs (string/split flc #":")
[pre [line column]]
(reduce
(fn [[pre post] [x i]]
(if (<= i 2)
[pre (conj post x)]
[(conj pre x) post]))
[[] []] (map vector xs (range (count xs) 0 -1)))
file (string/join ":" pre)]
[(cond-> file
(starts-with? file "(") (string/replace "(" ""))
(parse-int
(cond-> line
(ends-with? line ")") (string/replace ")" "")))
(parse-int
(cond-> column
(ends-with? column ")") (string/replace ")" "")))])))

(defn parse-file
"Given a browser file url convert it into a relative path that can be used
Expand Down Expand Up @@ -215,7 +217,7 @@
[file line column] (parse-file-line-column flc)]
(if (and file function line column)
{:file (parse-file repl-env file opts)
:function function
:function (string/trim function)
:line line
:column column}
(when-not (string/blank? function)
Expand Down Expand Up @@ -244,6 +246,14 @@
vec))

(comment
(parse-stacktrace {}
"cljs$core$seq@out/cljs/core.js:3999:17
cljs$core$first@out/cljs/core.js:4018:22
cljs$core$ffirst@out/cljs/core.js:5161:39
global code"
{:ua-product :safari}
{:output-dir "out"})

(parse-stacktrace {:host "localhost" :port 9000}
"cljs$core$seq@http://localhost:9000/out/cljs/core.js:4259:17
cljs$core$first@http://localhost:9000/out/cljs/core.js:4289:22
Expand Down

0 comments on commit 49f3ea9

Please sign in to comment.