SCI: use public stacktrace logic (#1017)
This commit is contained in:
parent
a39cdc7e8c
commit
7063021f19
2 changed files with 10 additions and 7 deletions
2
sci
2
sci
|
|
@ -1 +1 @@
|
||||||
Subproject commit 315e5ee6d6ce0b7f6ccac641ed79adde65dea666
|
Subproject commit d2d2e788d0ac708278f9a7ac0f265ae653cddd3b
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
[clojure.java.io :as io]
|
[clojure.java.io :as io]
|
||||||
[clojure.stacktrace :refer [print-stack-trace]]
|
[clojure.stacktrace :refer [print-stack-trace]]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[sci.impl.callstack :as cs]))
|
[sci.core :as sci]))
|
||||||
|
|
||||||
(defn ruler [title]
|
(defn ruler [title]
|
||||||
(println (apply str "----- " title " " (repeat (- 80 7 (count title)) \-))))
|
(println (apply str "----- " title " " (repeat (- 80 7 (count title)) \-))))
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
(defn print-stacktrace
|
(defn print-stacktrace
|
||||||
[stacktrace {:keys [:verbose?]}]
|
[stacktrace {:keys [:verbose?]}]
|
||||||
(let [stacktrace (cs/format-stacktrace stacktrace)
|
(let [stacktrace (sci/format-stacktrace stacktrace)
|
||||||
segments (split-stacktrace stacktrace verbose?)
|
segments (split-stacktrace stacktrace verbose?)
|
||||||
[fst snd] segments]
|
[fst snd] segments]
|
||||||
(run! println fst)
|
(run! println fst)
|
||||||
|
|
@ -76,6 +76,11 @@
|
||||||
;; print nil as nil
|
;; print nil as nil
|
||||||
(prn v)))))
|
(prn v)))))
|
||||||
|
|
||||||
|
(defn phase [ex stacktrace]
|
||||||
|
(or (:phase (ex-data ex))
|
||||||
|
(when (some :macro stacktrace)
|
||||||
|
"macroexpand")))
|
||||||
|
|
||||||
(defn error-handler [^Exception e opts]
|
(defn error-handler [^Exception e opts]
|
||||||
(binding [*out* *err*]
|
(binding [*out* *err*]
|
||||||
(let [d (ex-data e)
|
(let [d (ex-data e)
|
||||||
|
|
@ -85,9 +90,7 @@
|
||||||
ex-name (when sci-error?
|
ex-name (when sci-error?
|
||||||
(some-> ^Throwable (ex-cause e)
|
(some-> ^Throwable (ex-cause e)
|
||||||
.getClass .getName))
|
.getClass .getName))
|
||||||
stacktrace (some->
|
stacktrace (sci/stacktrace e)]
|
||||||
d :sci.impl/callstack
|
|
||||||
cs/stacktrace)]
|
|
||||||
(if exit-code
|
(if exit-code
|
||||||
(do
|
(do
|
||||||
(when-let [m (.getMessage e)]
|
(when-let [m (.getMessage e)]
|
||||||
|
|
@ -108,7 +111,7 @@
|
||||||
(println (str "Location: "
|
(println (str "Location: "
|
||||||
(when file (str file ":"))
|
(when file (str file ":"))
|
||||||
line ":" column""))))
|
line ":" column""))))
|
||||||
(when-let [phase (cs/phase e stacktrace)]
|
(when-let [phase (phase e stacktrace)]
|
||||||
(println "Phase: " phase))
|
(println "Phase: " phase))
|
||||||
(println)
|
(println)
|
||||||
(when-let [ec (when sci-error?
|
(when-let [ec (when sci-error?
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue