[fix] [#6] Missing root stack trace

Thanks to @FieryCod for the report!
This commit is contained in:
Peter Taoussanis 2024-05-07 13:42:16 +02:00
parent 21c0d5a791
commit 213c6470a7
2 changed files with 11 additions and 6 deletions

View file

@ -416,7 +416,7 @@
s+nl (enc/sb-appender sb enc/newline)]
(doseq [st-el (force trace)]
(let [{:keys [class method file line]} st-el]
(s+nl class "/" method " at " file ":" line)))
(s+nl " " class "/" method " at " file ":" line)))
(str sb))))
(comment (println (format-clj-stacktrace (:trace (enc/ex-map (ex-info "Ex2" {:k2 "v2"} (ex-info "Ex1" {:k1 "v1"})))))))
@ -446,8 +446,8 @@
(when trace
(s+ nl nl "Root stack trace:" nl)
#?(:cljs (s+ trace)
:clj (format-clj-stacktrace trace)))
#?(:cljs (s+ trace)
:clj (s+ (format-clj-stacktrace trace))))
(str sb)))))))

View file

@ -670,9 +670,14 @@
(is (= ((utils/format-nsecs-fn) 1.5e9) "1.50s")) ; More tests in Encore
(is (= ((utils/format-inst-fn) t0) "2024-06-09T21:15:20.170Z"))
(is (enc/str-starts-with? ((utils/format-error-fn) ex2)
#?(:clj " Root: clojure.lang.ExceptionInfo - Ex1\n data: {:k1 \"v1\"}\n\nCaused: clojure.lang.ExceptionInfo - Ex2\n data: {:k2 \"v2\"}\n\nRoot stack trace:\n"
:cljs " Root: cljs.core/ExceptionInfo - Ex1\n data: {:k1 \"v1\"}\n\nCaused: cljs.core/ExceptionInfo - Ex2\n data: {:k2 \"v2\"}\n\nRoot stack trace:\n")))
(testing "format-error-fn"
(let [ex2-str ((utils/format-error-fn) ex2)]
[(is (enc/str-starts-with? ex2-str
#?(:clj " Root: clojure.lang.ExceptionInfo - Ex1\n data: {:k1 \"v1\"}\n\nCaused: clojure.lang.ExceptionInfo - Ex2\n data: {:k2 \"v2\"}\n\nRoot stack trace:\n"
:cljs " Root: cljs.core/ExceptionInfo - Ex1\n data: {:k1 \"v1\"}\n\nCaused: cljs.core/ExceptionInfo - Ex2\n data: {:k2 \"v2\"}\n\nRoot stack trace:\n")))
(is (enc/str-contains? ex2-str "Root stack trace:"))
(is (enc/str-contains? ex2-str "invoke") "Root stack trace includes content")]))
(testing "signal-preamble-fn"
(let [sig (with-sig (tel/event! ::ev-id {:inst t0}))