Skip to content

Commit 4ddd878

Browse files
tonskyswannodette
authored andcommitted
CLJS-1101 cljs.test might throw when trying to detect file-and-line
1 parent 70e73c5 commit 4ddd878

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/cljs/cljs/test.cljs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -372,19 +372,18 @@
372372
default)))
373373

374374
(defn file-and-line [exception depth]
375-
(let [stack (.-stack exception)]
376-
(if (and stack (string? stack))
377-
;; TODO: flesh out
378-
(let [stacktrace
379-
(vec (map string/trim
380-
(string/split stack #"\n")))
381-
stack-element (nth stacktrace depth)
382-
fname (js-filename stack-element)
383-
[line column] (js-line-and-column stack-element)
384-
[fname line column] (mapped-line-and-column fname line column)]
385-
{:file fname :line line :column column})
386-
{:file (.-fileName exception)
387-
:line (.-lineNumber exception)})) )
375+
;; TODO: flesh out
376+
(if-let [stack-element (and (string? (.-stack exception))
377+
(some-> (.-stack exception)
378+
string/split-lines
379+
(get depth)
380+
string/trim))]
381+
(let [fname (js-filename stack-element)
382+
[line column] (js-line-and-column stack-element)
383+
[fname line column] (mapped-line-and-column fname line column)]
384+
{:file fname :line line :column column})
385+
{:file (.-fileName exception)
386+
:line (.-lineNumber exception)}))
388387

389388
(defn do-report [m]
390389
(let [m (case (:type m)

0 commit comments

Comments
 (0)