Liking cljdoc? Tell your friends :D
Clojure only.

shuriken.exception

### Macros to deal with exceptions
raw docstring

silencecljmacro

(silence target expr)
(silence substitute target expr)

Returns substitute if expr raises an exception that matches target. If not provided, substitute is nil. Target can be:

  • a class
  • a sequence of classes
  • a predicate
  • a string
(silence ArithmeticException (/ 1 0))
=> nil

(silence "Divide by zero" (/ 1 0))
=> nil

(silence [ArithmeticException]
  (do (println "watch out !")
      (/ 1 0)))
;; watch out !
=> nil

(silence :substitute
         (fn [x]
           (isa? (class x) ArithmeticException))
         (/ 1 0))
=> :substitute
Returns `substitute` if `expr` raises an exception that matches
`target`.
If not provided, `substitute` is `nil`.
Target can be:
  - a class
  - a sequence of classes
  - a predicate
  - a string

```clojure
(silence ArithmeticException (/ 1 0))
=> nil

(silence "Divide by zero" (/ 1 0))
=> nil

(silence [ArithmeticException]
  (do (println "watch out !")
      (/ 1 0)))
;; watch out !
=> nil

(silence :substitute
         (fn [x]
           (isa? (class x) ArithmeticException))
         (/ 1 0))
=> :substitute
```
sourceraw docstring

thrown?cljmacro

(thrown? target expr)
source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close