Skip to content

Commit dd03c24

Browse files
committed
Print more stacktraces in CI
Sometimes stacktraces can be swallowed. That can be fine, but it is cautious to log all stacktraces in CI. That can help debugging heisenbugs etc.
1 parent 4c2b701 commit dd03c24

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

project.clj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,7 @@
7474
:exclude-linters [:implicit-dependencies]}}
7575
:clj-kondo [:test
7676
{:dependencies [[clj-kondo "2021.06.18"]]}]}
77-
:jvm-opts ["-Djava.net.preferIPv4Stack=true"])
77+
78+
:jvm-opts ~(cond-> ["-Djava.net.preferIPv4Stack=true"]
79+
(System/getenv "CI")
80+
(conj "-Drefactor-nrepl.internal.log-exceptions=true")))

src/refactor_nrepl/analyzer.clj

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@
9191
(when ns
9292
(if-let [cached-ast-or-err (get-ast-from-cache ns file-content)]
9393
cached-ast-or-err
94-
(when-let [new-ast-or-err (try (build-ast ns aliases) (catch Throwable th th))]
94+
(when-let [new-ast-or-err (try
95+
(build-ast ns aliases)
96+
(catch Throwable th
97+
(when (System/getProperty "refactor-nrepl.internal.log-exceptions")
98+
(-> th .printStackTrace))
99+
th))]
95100
(update-ast-cache file-content ns new-ast-or-err))))))
96101

97102
(defn- throw-ast-in-bad-state
@@ -131,7 +136,11 @@
131136
(doseq [f (tracker/project-files-in-topo-order)]
132137
(try
133138
(ns-ast (slurp f))
134-
(catch Throwable _th))) ;noop, ast-status will be reported separately
139+
(catch Throwable th
140+
(when (System/getProperty "refactor-nrepl.internal.log-exceptions")
141+
(-> th .printStackTrace))
142+
nil ; noop, ast-status will be reported separately
143+
)))
135144
(ast-stats))
136145

137146
(defn node-at-loc? [^long loc-line ^long loc-column node]

src/refactor_nrepl/find/find_macros.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
(mapcat #(try
8686
(get-macro-definitions-in-file-with-caching %)
8787
(catch Exception e
88+
(when (System/getProperty "refactor-nrepl.internal.log-exceptions")
89+
(-> e .printStackTrace))
8890
(when-not ignore-errors?
8991
(throw e)))))))
9092

src/refactor_nrepl/find/find_symbol.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@
109109
(find-symbol-in-ast fully-qualified-name)
110110
(filter :line-beg))
111111
(catch Exception e
112+
(when (System/getProperty "refactor-nrepl.internal.log-exceptions")
113+
(-> e .printStackTrace))
112114
(when-not ignore-errors
113115
(throw e))))
114116
locs (into

test/refactor_nrepl/integration_tests.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
(defn ns-ast-throw-error-for-five [^String content]
5454
(if (.contains content "com.example.five")
55-
(throw (IllegalThreadStateException. "FAILED!"))
55+
(throw (IllegalThreadStateException. "Expected!"))
5656
(#'analyzer/cachable-ast content)))
5757

5858
(deftest test-find-two-foo-errors-ignored

0 commit comments

Comments
 (0)