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 253253 (flag-duplicates )
254254 (flag-tooling ))))
255255
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-
266256(defn- analyze-cause
267257 " Analyze the `cause-data` of an exception, in `Throwable->map` format."
268258 [cause-data print-fn]
272262 phase (-> cause-data :data :clojure.error/phase )
273263 m {:class (name (:type cause-data))
274264 :phase phase
275- :compile-like (str (compile-like-exception? cause-data))
276265 :message (:message cause-data)
277266 :stacktrace (analyze-stacktrace-data
278267 (cond (seq (:trace cause-data)) (:trace cause-data)
Original file line number Diff line number Diff line change 256256
257257 (testing " Does not include `:phase` for vanilla runtime exceptions"
258258 (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 " " {})))))))
277260
278261(deftest tooling-frame-name?
279262 (are [frame-name] (true ? (#'sut/tooling-frame-name? frame-name))
You can’t perform that action at this time.
0 commit comments