|
199 | 199 |
|
200 | 200 | (defmulti parse-stacktrace (fn [repl-env st err opts] (:ua-product err)))
|
201 | 201 |
|
| 202 | +(defmethod parse-stacktrace :default |
| 203 | + [repl-env st err opts] st) |
| 204 | + |
202 | 205 | (defn parse-file-line-column [flc]
|
203 | 206 | (let [xs (string/split flc #":")
|
204 | 207 | [pre [line column]]
|
@@ -353,6 +356,100 @@ http://localhost:9000/out/goog/events/events.js:276:42"
|
353 | 356 | nil)
|
354 | 357 | )
|
355 | 358 |
|
| 359 | +;; ----------------------------------------------------------------------------- |
| 360 | +;; Firefox Stacktrace |
| 361 | + |
| 362 | +(defn firefox-clean-function [f] |
| 363 | + (as-> f f |
| 364 | + (cond |
| 365 | + (string/blank? f) nil |
| 366 | + (not= (.indexOf f "</") -1) |
| 367 | + (let [idx (.indexOf f "</")] |
| 368 | + (.substring f (+ idx 2))) |
| 369 | + :else f) |
| 370 | + (-> f |
| 371 | + (string/replace #"<" "") |
| 372 | + (string/replace #"\/" "")))) |
| 373 | + |
| 374 | +(defn firefox-st-el->frame |
| 375 | + [st-el opts] |
| 376 | + (let [[function flc] (if (re-find #"@" st-el) |
| 377 | + (string/split st-el #"@") |
| 378 | + [nil st-el]) |
| 379 | + [file line column] (parse-file-line-column flc)] |
| 380 | + (if (and file function line column) |
| 381 | + {:file (parse-file file opts) |
| 382 | + :function (firefox-clean-function function) |
| 383 | + :line line |
| 384 | + :column column} |
| 385 | + (when-not (string/blank? function) |
| 386 | + {:file nil |
| 387 | + :function (firefox-clean-function function) |
| 388 | + :line nil |
| 389 | + :column nil})))) |
| 390 | + |
| 391 | +(comment |
| 392 | + (firefox-st-el->frame |
| 393 | + "cljs$core$seq@http://localhost:9000/out/cljs/core.js:4258:8" {}) |
| 394 | + |
| 395 | + (firefox-st-el->frame |
| 396 | + "cljs.core.map</cljs$core$map__2/</<@http://localhost:9000/out/cljs/core.js:16971:87" {}) |
| 397 | + |
| 398 | + (firefox-st-el->frame |
| 399 | + "cljs.core.map</cljs$core$map__2/</<@http://localhost:9000/out/cljs/core.js:16971:87" {}) |
| 400 | + |
| 401 | + (firefox-st-el->frame |
| 402 | + "cljs.core.pr_str</cljs$core$pr_str@http://localhost:9000/out/cljs/core.js:29138:8" {}) |
| 403 | + |
| 404 | + (firefox-st-el->frame |
| 405 | + "cljs.core.pr_str</cljs$core$pr_str__delegate@http://localhost:9000/out/cljs/core.js:29129:8" {}) |
| 406 | + ) |
| 407 | + |
| 408 | +(defmethod parse-stacktrace :firefox |
| 409 | + [repl-env st err opts] |
| 410 | + (->> st |
| 411 | + string/split-lines |
| 412 | + (take-while #(= (.indexOf % "> eval") -1)) |
| 413 | + (remove string/blank?) |
| 414 | + (map #(firefox-st-el->frame % opts)) |
| 415 | + (remove nil?) |
| 416 | + vec)) |
| 417 | + |
| 418 | +(comment |
| 419 | + (parse-stacktrace nil |
| 420 | + "cljs$core$seq@http://localhost:9000/out/cljs/core.js:4258:8 |
| 421 | +cljs$core$first@http://localhost:9000/out/cljs/core.js:4288:9 |
| 422 | +cljs$core$ffirst@http://localhost:9000/out/cljs/core.js:5356:24 |
| 423 | +cljs.core.map</cljs$core$map__2/</<@http://localhost:9000/out/cljs/core.js:16971:87 |
| 424 | +cljs.core.map</cljs$core$map__2/<@http://localhost:9000/out/cljs/core.js:16970:1 |
| 425 | +cljs.core.LazySeq.prototype.sval/self__.s<@http://localhost:9000/out/cljs/core.js:10981:119 |
| 426 | +cljs.core.LazySeq.prototype.sval@http://localhost:9000/out/cljs/core.js:10981:13 |
| 427 | +cljs.core.LazySeq.prototype.cljs$core$ISeqable$_seq$arity$1@http://localhost:9000/out/cljs/core.js:11073:1 |
| 428 | +cljs$core$seq@http://localhost:9000/out/cljs/core.js:4239:8 |
| 429 | +cljs$core$pr_sequential_writer@http://localhost:9000/out/cljs/core.js:28706:4 |
| 430 | +cljs.core.LazySeq.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3@http://localhost:9000/out/cljs/core.js:29385:8 |
| 431 | +cljs$core$pr_writer_impl@http://localhost:9000/out/cljs/core.js:28911:8 |
| 432 | +cljs$core$pr_writer@http://localhost:9000/out/cljs/core.js:29010:8 |
| 433 | +cljs$core$pr_seq_writer@http://localhost:9000/out/cljs/core.js:29014:1 |
| 434 | +cljs$core$pr_sb_with_opts@http://localhost:9000/out/cljs/core.js:29077:1 |
| 435 | +cljs$core$pr_str_with_opts@http://localhost:9000/out/cljs/core.js:29091:23 |
| 436 | +cljs.core.pr_str</cljs$core$pr_str__delegate@http://localhost:9000/out/cljs/core.js:29129:8 |
| 437 | +cljs.core.pr_str</cljs$core$pr_str@http://localhost:9000/out/cljs/core.js:29138:8 |
| 438 | +@http://localhost:9000/out/clojure/browser/repl.js line 23 > eval:1:25 |
| 439 | +@http://localhost:9000/out/clojure/browser/repl.js line 23 > eval:1:2 |
| 440 | +clojure$browser$repl$evaluate_javascript/result<@http://localhost:9000/out/clojure/browser/repl.js:23:267 |
| 441 | +clojure$browser$repl$evaluate_javascript@http://localhost:9000/out/clojure/browser/repl.js:23:15 |
| 442 | +clojure$browser$repl$connect/</<@http://localhost:9000/out/clojure/browser/repl.js:121:128 |
| 443 | +goog.messaging.AbstractChannel.prototype.deliver@http://localhost:9000/out/goog/messaging/abstractchannel.js:142:5 |
| 444 | +goog.net.xpc.CrossPageChannel.prototype.xpcDeliver@http://localhost:9000/out/goog/net/xpc/crosspagechannel.js:733:7 |
| 445 | +goog.net.xpc.NativeMessagingTransport.messageReceived_@http://localhost:9000/out/goog/net/xpc/nativemessagingtransport.js:321:1 |
| 446 | +goog.events.fireListener@http://localhost:9000/out/goog/events/events.js:741:10 |
| 447 | +goog.events.handleBrowserEvent_@http://localhost:9000/out/goog/events/events.js:862:1 |
| 448 | +goog.events.getProxy/f<@http://localhost:9000/out/goog/events/events.js:276:16" |
| 449 | + {:ua-product :firefox} |
| 450 | + nil) |
| 451 | + ) |
| 452 | + |
356 | 453 | ;; =============================================================================
|
357 | 454 | ;; BrowserEnv
|
358 | 455 |
|
|
0 commit comments