Print exception name

This commit is contained in:
Michiel Borkent 2020-05-23 21:23:57 +02:00
parent 5e051a2d6e
commit 6aeb0869f8
4 changed files with 18 additions and 8 deletions

@ -1 +1 @@
Subproject commit 0092be5f97bc01f343b2e0619cbf1fe39149d498
Subproject commit 38eef3c9eefe30944fc87127e715ed177ff425a8

2
sci

@ -1 +1 @@
Subproject commit efcbbc704bcf7fab513cda5fd8b9876bf30fedfe
Subproject commit f12f5caa82011412fd4d5cc3bb506d0a18b6d51d

View file

@ -17,10 +17,15 @@
"Default :caught hook for repl"
[^Throwable e]
(sci/with-bindings {sci/out @sci/err}
(sio/println (str (.. e getClass getName)
(when-let [m (.getMessage e)]
(str ": " m)) ))
(sio/flush)))
(let [d (ex-data e)
sci-error? (identical? :sci/error (:type d))
ex-name (when sci-error?
(some-> ^Throwable (ex-cause e)
.getClass .getName))]
(sio/println (str ex-name
(when-let [m (.getMessage e)]
(str ": " m)) ))
(sio/flush))))
(defn repl
"REPL with predefined hooks for attachable socket server."

View file

@ -379,11 +379,16 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that
(defn error-handler* [^Exception e verbose?]
(binding [*out* *err*]
(let [d (ex-data e)
exit-code (:bb/exit-code d)]
exit-code (:bb/exit-code d)
sci-error? (identical? :sci/error (:type d))
ex-name (when sci-error?
(some-> ^Throwable (ex-cause e)
.getClass .getName))]
(if exit-code [nil exit-code]
(do (if verbose?
(print-stack-trace e)
(println (str (.. e getClass getName)
(println (str (or ex-name
(.. e getClass getName))
(when-let [m (.getMessage e)]
(str ": " m)) )))
(flush)