|
10 | 10 | (:refer-clojure :exclude [loaded-libs]) |
11 | 11 | (:require [clojure.java.io :as io] |
12 | 12 | [clojure.string :as string] |
| 13 | + [clojure.edn :as edn] |
13 | 14 | [cljs.compiler :as comp] |
14 | 15 | [cljs.util :as util] |
15 | 16 | [cljs.env :as env] |
|
265 | 266 | [repl-env st err opts] |
266 | 267 | (->> st |
267 | 268 | string/split-lines |
268 | | - (drop 1) ;; drop the error message |
| 269 | + (drop-while #(.startsWith % "Error")) |
269 | 270 | (take-while #(not (.startsWith % " at eval"))) |
270 | 271 | (map #(chrome-st-el->frame % opts)) |
271 | 272 | (remove nil?) |
272 | 273 | vec)) |
273 | 274 |
|
274 | 275 | (comment |
275 | 276 | (parse-stacktrace nil |
276 | | - "\tat Object.cljs$core$seq [as seq] (http://localhost:9000/out/cljs/core.js:4258:8) |
277 | | -\tat Object.cljs$core$first [as first] (http://localhost:9000/out/cljs/core.js:4288:19) |
278 | | -\tat cljs$core$ffirst (http://localhost:9000/out/cljs/core.js:5356:34) |
279 | | -\tat http://localhost:9000/out/cljs/core.js:16971:89 |
280 | | -\tat cljs.core.map.cljs$core$map__2 (http://localhost:9000/out/cljs/core.js:16972:3) |
281 | | -\tat http://localhost:9000/out/cljs/core.js:10981:129 |
282 | | -\tat cljs.core.LazySeq.sval (http://localhost:9000/out/cljs/core.js:10982:3) |
283 | | -\tat cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (http://localhost:9000/out/cljs/core.js:11073:10) |
284 | | -\tat Object.cljs$core$seq [as seq] (http://localhost:9000/out/cljs/core.js:4239:13) |
285 | | -\tat Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] (http://localhost:9000/out/cljs/core.js:28706:14)" |
| 277 | + "Error: 1 is not ISeqable |
| 278 | + at Object.cljs$core$seq [as seq] (http://localhost:9000/out/cljs/core.js:4258:8) |
| 279 | + at Object.cljs$core$first [as first] (http://localhost:9000/out/cljs/core.js:4288:19) |
| 280 | + at cljs$core$ffirst (http://localhost:9000/out/cljs/core.js:5356:34) |
| 281 | + at http://localhost:9000/out/cljs/core.js:16971:89 |
| 282 | + at cljs.core.map.cljs$core$map__2 (http://localhost:9000/out/cljs/core.js:16972:3) |
| 283 | + at http://localhost:9000/out/cljs/core.js:10981:129 |
| 284 | + at cljs.core.LazySeq.sval (http://localhost:9000/out/cljs/core.js:10982:3) |
| 285 | + at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (http://localhost:9000/out/cljs/core.js:11073:10) |
| 286 | + at Object.cljs$core$seq [as seq] (http://localhost:9000/out/cljs/core.js:4239:13) |
| 287 | + at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] (http://localhost:9000/out/cljs/core.js:28706:14)" |
286 | 288 | {:ua-product :chrome} |
287 | 289 | nil) |
288 | 290 |
|
289 | 291 | (parse-stacktrace nil |
290 | | - "at Object.cljs$core$seq [as seq] (http://localhost:9000/out/cljs/core.js:4259:8) |
291 | | -\tat Object.cljs$core$first [as first] (http://localhost:9000/out/cljs/core.js:4289:19) |
292 | | -\tat cljs$core$ffirst (http://localhost:9000/out/cljs/core.js:5357:18) |
293 | | -\tat eval (eval at <anonymous> (http://localhost:9000/out/clojure/browser/repl.js:23:272), <anonymous>:1:106) |
294 | | -\tat eval (eval at <anonymous> (http://localhost:9000/out/clojure/browser/repl.js:23:272), <anonymous>:9:3) |
295 | | -\tat eval (eval at <anonymous> (http://localhost:9000/out/clojure/browser/repl.js:23:272), <anonymous>:14:4) |
296 | | -\tat http://localhost:9000/out/clojure/browser/repl.js:23:267 |
297 | | -\tat clojure$browser$repl$evaluate_javascript (http://localhost:9000/out/clojure/browser/repl.js:26:4) |
298 | | -\tat Object.callback (http://localhost:9000/out/clojure/browser/repl.js:121:169) |
299 | | -\tat goog.messaging.AbstractChannel.deliver (http://localhost:9000/out/goog/messaging/abstractchannel.js:142:13)" |
| 292 | + "Error: 1 is not ISeqable |
| 293 | + at Object.cljs$core$seq [as seq] (http://localhost:9000/out/cljs/core.js:4259:8) |
| 294 | + at Object.cljs$core$first [as first] (http://localhost:9000/out/cljs/core.js:4289:19) |
| 295 | + at cljs$core$ffirst (http://localhost:9000/out/cljs/core.js:5357:18) |
| 296 | + at eval (eval at <anonymous> (http://localhost:9000/out/clojure/browser/repl.js:23:272), <anonymous>:1:106) |
| 297 | + at eval (eval at <anonymous> (http://localhost:9000/out/clojure/browser/repl.js:23:272), <anonymous>:9:3) |
| 298 | + at eval (eval at <anonymous> (http://localhost:9000/out/clojure/browser/repl.js:23:272), <anonymous>:14:4) |
| 299 | + at http://localhost:9000/out/clojure/browser/repl.js:23:267 |
| 300 | + at clojure$browser$repl$evaluate_javascript (http://localhost:9000/out/clojure/browser/repl.js:26:4) |
| 301 | + at Object.callback (http://localhost:9000/out/clojure/browser/repl.js:121:169) |
| 302 | + at goog.messaging.AbstractChannel.deliver (http://localhost:9000/out/goog/messaging/abstractchannel.js:142:13)" |
300 | 303 | {:ua-product :chrome} |
301 | 304 | nil) |
302 | 305 | ) |
|
330 | 333 | [repl-env st err opts] |
331 | 334 | (->> st |
332 | 335 | string/split-lines |
| 336 | + (drop-while #(.startsWith % "Error")) |
333 | 337 | (take-while #(not (.startsWith % "eval code"))) |
334 | 338 | (remove string/blank?) |
335 | 339 | (map #(safari-st-el->frame % opts)) |
@@ -424,6 +428,7 @@ http://localhost:9000/out/goog/events/events.js:276:42" |
424 | 428 | [repl-env st err opts] |
425 | 429 | (->> st |
426 | 430 | string/split-lines |
| 431 | + (drop-while #(.startsWith % "Error")) |
427 | 432 | (take-while #(= (.indexOf % "> eval") -1)) |
428 | 433 | (remove string/blank?) |
429 | 434 | (map #(firefox-st-el->frame % opts)) |
@@ -475,6 +480,15 @@ goog.events.getProxy/f<@http://localhost:9000/out/goog/events/events.js:276:16" |
475 | 480 | repl/IParseStacktrace |
476 | 481 | (-parse-stacktrace [this st err opts] |
477 | 482 | (parse-stacktrace this st err opts)) |
| 483 | + repl/IGetError |
| 484 | + (-get-error [this e env opts] |
| 485 | + (edn/read-string |
| 486 | + (repl/evaluate-form this env "<cljs repl>" |
| 487 | + `(when ~e |
| 488 | + (pr-str |
| 489 | + {:ua-product (clojure.browser.repl/get-ua-product) |
| 490 | + :value (str ~e) |
| 491 | + :stacktrace (.-stack ~e)}))))) |
478 | 492 | (-evaluate [_ _ _ js] (browser-eval js)) |
479 | 493 | (-load [this provides url] |
480 | 494 | (load-javascript this provides url)) |
|
0 commit comments