diff --git a/sci b/sci index 315e5ee6..d2d2e788 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 315e5ee6d6ce0b7f6ccac641ed79adde65dea666 +Subproject commit d2d2e788d0ac708278f9a7ac0f265ae653cddd3b diff --git a/src/babashka/impl/error_handler.clj b/src/babashka/impl/error_handler.clj index e941c8ef..9eaafe83 100644 --- a/src/babashka/impl/error_handler.clj +++ b/src/babashka/impl/error_handler.clj @@ -4,7 +4,7 @@ [clojure.java.io :as io] [clojure.stacktrace :refer [print-stack-trace]] [clojure.string :as str] - [sci.impl.callstack :as cs])) + [sci.core :as sci])) (defn ruler [title] (println (apply str "----- " title " " (repeat (- 80 7 (count title)) \-)))) @@ -19,7 +19,7 @@ (defn print-stacktrace [stacktrace {:keys [:verbose?]}] - (let [stacktrace (cs/format-stacktrace stacktrace) + (let [stacktrace (sci/format-stacktrace stacktrace) segments (split-stacktrace stacktrace verbose?) [fst snd] segments] (run! println fst) @@ -76,6 +76,11 @@ ;; print nil as nil (prn v))))) +(defn phase [ex stacktrace] + (or (:phase (ex-data ex)) + (when (some :macro stacktrace) + "macroexpand"))) + (defn error-handler [^Exception e opts] (binding [*out* *err*] (let [d (ex-data e) @@ -85,9 +90,7 @@ ex-name (when sci-error? (some-> ^Throwable (ex-cause e) .getClass .getName)) - stacktrace (some-> - d :sci.impl/callstack - cs/stacktrace)] + stacktrace (sci/stacktrace e)] (if exit-code (do (when-let [m (.getMessage e)] @@ -108,7 +111,7 @@ (println (str "Location: " (when file (str file ":")) line ":" column"")))) - (when-let [phase (cs/phase e stacktrace)] + (when-let [phase (phase e stacktrace)] (println "Phase: " phase)) (println) (when-let [ec (when sci-error?