Improve trace reporting on unhandled exception

This commit is contained in:
Andrey Antukh 2022-12-31 10:49:04 +01:00
parent 3b61a7dd91
commit 7a8b0e710b

View file

@ -30,7 +30,14 @@
[error] [error]
(cond (cond
(instance? ExceptionInfo error) (instance? ExceptionInfo error)
(-> error ex-data ptk/handle-error) (let [data (ex-data error)]
(if (contains? data :type)
(ptk/handle-error data)
(let [hint (str/ffmt "Unexpected error: '%'" (ex-message error))]
(ts/schedule #(st/emit! (rt/assign-exception error)))
(js/console.group hint)
(js/console.log (.-stack error))
(js/console.groupEnd hint))))
(map? error) (map? error)
(ptk/handle-error error) (ptk/handle-error error)
@ -49,7 +56,7 @@
(defmethod ptk/handle-error :default (defmethod ptk/handle-error :default
[error] [error]
(let [hint (str/concat "Unexpected error: " (:hint error))] (let [hint (str/ffmt "Unhandled error: '%'" (:hint error "[no hint]"))]
(ts/schedule #(st/emit! (rt/assign-exception error))) (ts/schedule #(st/emit! (rt/assign-exception error)))
(js/console.group hint) (js/console.group hint)
(ex/ignoring (js/console.error (pr-str error))) (ex/ignoring (js/console.error (pr-str error)))