File tree Expand file tree Collapse file tree 2 files changed +1
-29
lines changed Expand file tree Collapse file tree 2 files changed +1
-29
lines changed Original file line number Diff line number Diff line change 253
253
(flag-duplicates )
254
254
(flag-tooling ))))
255
255
256
- (defn- compile-like-exception?
257
- " 'Compile-like' exceptions are those that happen at runtime (and therefore never
258
- include a `:phase`) which however, represent code that cannot possibly work,
259
- and thus are a compile-like exception (i.e. a linter could have caught them)."
260
- [{:keys [phase type message]}]
261
- (boolean
262
- (and (nil? phase)
263
- (= type 'java.lang.IllegalArgumentException)
264
- (some->> message (re-find #"^No matching (field|method)" )))))
265
-
266
256
(defn- analyze-cause
267
257
" Analyze the `cause-data` of an exception, in `Throwable->map` format."
268
258
[cause-data print-fn]
272
262
phase (-> cause-data :data :clojure.error/phase )
273
263
m {:class (name (:type cause-data))
274
264
:phase phase
275
- :compile-like (str (compile-like-exception? cause-data))
276
265
:message (:message cause-data)
277
266
:stacktrace (analyze-stacktrace-data
278
267
(cond (seq (:trace cause-data)) (:trace cause-data)
Original file line number Diff line number Diff line change 256
256
257
257
(testing " Does not include `:phase` for vanilla runtime exceptions"
258
258
(is (match? [{:phase nil }]
259
- (catch-and-analyze (throw (ex-info " " {}))))))
260
-
261
- (testing " `:compile-like`"
262
- (testing " For non-existing fields"
263
- (is (match? [{:compile-like " true" }]
264
- (catch-and-analyze (eval '(.-foo " " ))))))
265
- (testing " For non-existing methods"
266
- (is (match? [{:compile-like " true" }]
267
- (catch-and-analyze (eval '(-> " " (.foo 1 2 )))))))
268
- (testing " For vanilla exceptions"
269
- (is (match? [{:compile-like " false" }]
270
- (catch-and-analyze (throw (ex-info " ." {}))))))
271
- (testing " For vanilla `IllegalArgumentException`s"
272
- (is (match? [{:compile-like " false" }]
273
- (catch-and-analyze (throw (IllegalArgumentException. " foo" ))))))
274
- (testing " For exceptions with a `:phase`"
275
- (is (match? [{:compile-like " false" } {:compile-like " false" }]
276
- (catch-and-analyze (eval '(let [1 ]))))))))
259
+ (catch-and-analyze (throw (ex-info " " {})))))))
277
260
278
261
(deftest tooling-frame-name?
279
262
(are [frame-name] (true ? (#'sut/tooling-frame-name? frame-name))
You can’t perform that action at this time.
0 commit comments