Skip to content

Commit 6cf8b44

Browse files
author
dnolen
committed
make cljs.stacktrace/parse-file more flexible - if :host not present but :output-dir
is, just rely on :output-dir
1 parent 161e6ac commit 6cf8b44

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

src/main/cljs/cljs/stacktrace.cljc

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,16 @@
6666
"Given a browser file url convert it into a relative path that can be used
6767
to locate the original source."
6868
[{:keys [host host-port port] :as repl-env} file {:keys [asset-path] :as opts}]
69-
(let [base-url-pattern (string->regex (str "http://" host ":" (or host-port port) "/"))]
70-
(if (re-find base-url-pattern file)
69+
(let [urlpat (if host
70+
(string->regex
71+
(str "http://" host ":" (or host-port port) "/"))
72+
"")
73+
match (if host
74+
(re-find urlpat file)
75+
(contains? opts :output-dir))]
76+
(if match
7177
(-> file
72-
(string/replace base-url-pattern "")
78+
(string/replace urlpat "")
7379
(string/replace
7480
(string->regex
7581
;; if :asset-path specified drop leading slash
@@ -166,6 +172,22 @@
166172
at goog.messaging.AbstractChannel.deliver (http://localhost:9000/out/goog/messaging/abstractchannel.js:142:13)"
167173
{:ua-product :chrome}
168174
nil)
175+
176+
;; Node.js example
177+
(parse-stacktrace {}
178+
"Error: 1 is not ISeqable
179+
at Object.cljs$core$seq [as seq] (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:3999:8)
180+
at Object.cljs$core$first [as first] (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:4018:19)
181+
at cljs$core$ffirst (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:5161:34)
182+
at /home/my/cool/project/.cljs_bootstrap/cljs/core.js:16006:88
183+
at cljs.core.map.cljs$core$IFn$_invoke$arity$2 (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:16007:3)
184+
at cljs.core.LazySeq.sval (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:10244:109)
185+
at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:10335:10)
186+
at Object.cljs$core$seq [as seq] (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:3980:13)
187+
at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:28084:14)
188+
at cljs.core.LazySeq.cljs$core$IPrintWithWriter$_pr_writer$arity$3 (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:28812:18)"
189+
{:ua-product :chrome}
190+
{:output-dir "/home/my/cool/project/.cljs_bootstrap"})
169191
)
170192

171193
;; -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)