Skip to content

Commit

Permalink
[fix] [#6] Missing root stack trace
Browse files Browse the repository at this point in the history
Thanks to @FieryCod for the report!
  • Loading branch information
ptaoussanis committed May 7, 2024
1 parent 21c0d5a commit 213c647
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/taoensso/telemere/utils.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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"})))))))
Expand Down Expand Up @@ -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)))))))

Expand Down
11 changes: 8 additions & 3 deletions test/taoensso/telemere_tests.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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}))
Expand Down

0 comments on commit 213c647

Please sign in to comment.