File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,26 @@ Enhanced throw and catch for Clojure
109109
110110 The wrapper is available via the ` :wrapper ` key in ` &throw-context ` .
111111
112+ ``` clojure
113+ user=> (defn foo [x]
114+ #_=> (throw (ex-info " important message" {:value x})))
115+ #_=>
116+ #_=> (defn -main []
117+ #_=> (try+
118+ #_=> (foo 5 )
119+ #_=> (catch Object e
120+ #_=> (println " caught" e &throw-context))))
121+ #'user/foo
122+ #'user/-main
123+ user=> (-main )
124+ caught {:value 5 } {:object {:value 5 }, :message important message, :cause nil,
125+ :stack-trace #object[[Ljava.lang.StackTraceElement...],
126+ :wrapper #error {
127+ :cause important message
128+ ...},
129+ :throwable #error {...}}
130+ ```
131+
112132 Between being thrown and caught, a wrapper may be further wrapped by
113133 other Exceptions (e.g., instances of `RuntimeException` or
114134 `java.util.concurrent.ExecutionException`). `try+` sees through all
You can’t perform that action at this time.
0 commit comments