File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -2240,6 +2240,29 @@ throw an exception -- throws an exception of a standard type
2240
2240
2241
2241
Favor `with-open` over `finally`.
2242
2242
2243
+ === Catching Throwables [[catching-throwables]]
2244
+
2245
+ Don't catch `Throwable`. It is a superclass of all Errors and Exceptions in
2246
+ Java, and as such, it will swallow _all_ possible Errors. As explained by the
2247
+ Java documentation on the `Error` class, "An Error is a subclass of Throwable
2248
+ that indicates serious problems that a reasonable application should not try to
2249
+ catch."
2250
+
2251
+ Under certain circumstances, it is necessary to catch Errors. In those cases,
2252
+ catch specific Errors.
2253
+
2254
+ [source,clojure]
2255
+ ----
2256
+ ;; good
2257
+ (try (foo)
2258
+ (catch ExceptionInfo ex ...)
2259
+ (catch AssertionError t ...))
2260
+
2261
+ ;; bad
2262
+ (try (foo)
2263
+ (catch Throwable t ...))
2264
+ ----
2265
+
2243
2266
== Macros
2244
2267
2245
2268
=== Don't Write a Macro If a Function Will Do [[dont-write-macro-if-fn-will-do]]
You can’t perform that action at this time.
0 commit comments