(assert-with pred v msg)
If (pred v) is true, return v otherwise, return (f/fail msg)
If (pred v) is true, return v otherwise, return (f/fail msg)
(attempt-> start)
(attempt-> start form)
(attempt-> start form & forms)
Deprecated. Use ok-> instead.
Deprecated. Use ok-> instead.
(attempt->> start)
(attempt->> start form)
(attempt->> start form & forms)
Deprecated. Use ok->> instead.
Deprecated. Use ok->> instead.
(attempt-all bindings return)
(attempt-all bindings return else)
Used like let
, but short-circuits in case of
a failed binding. Can be used in combination with when-failed
to handle the failure.
Unlike let
, only accepts a single form to execute after the bindings.
(attempt-all [x "Ok" y (fail "Fail")] x (when-failed [e] (message e))) ; => "Fail"
Used like `let`, but short-circuits in case of a failed binding. Can be used in combination with when-failed to handle the failure. Unlike `let`, only accepts a single form to execute after the bindings. (attempt-all [x "Ok" y (fail "Fail")] x (when-failed [e] (message e))) ; => "Fail"
(if-failed arglist & body)
DEPRECATED: Use when-failed instead
DEPRECATED: Use when-failed instead
(if-let-failed? [v-sym form] failed-branch)
(if-let-failed? [v-sym form] failed-branch ok-branch)
Inverse of if-let-ok?
(if-let-failed? [v (some-fn)] (prn "V Failed!") (prn "V is OK!"))
If called with 1 branch, returns the value in case of non-failure:
(if-let-failed? [v "Hello"] (prn "V Failed!")) ;; => returns "Hello"
Inverse of if-let-ok? (if-let-failed? [v (some-fn)] (prn "V Failed!") (prn "V is OK!")) If called with 1 branch, returns the value in case of non-failure: (if-let-failed? [v "Hello"] (prn "V Failed!")) ;; => returns "Hello"
(if-let-ok? [v-sym form] ok-branch)
(if-let-ok? [v-sym form] ok-branch failed-branch)
Binding convenience.
Acts just like let for non-failing values:
(if-let-ok? [v (something-which-may-fail)] (do-something-else v) (do-something-on-failure v))
Note that the value of v is the result of something-which-may-fail in either case. If no else branch is provided, nil is returned:
(if-let-ok? [v (fail "Goodbye")] "Hello") ;; Returns #failjure.core.Failure{:message "Goodbye"}
Note that the above is identical in function to simply calling (fail "Goodbye")
Binding convenience. Acts just like let for non-failing values: (if-let-ok? [v (something-which-may-fail)] (do-something-else v) (do-something-on-failure v)) Note that the value of v is the result of something-which-may-fail in either case. If no else branch is provided, nil is returned: (if-let-ok? [v (fail "Goodbye")] "Hello") ;; Returns #failjure.core.Failure{:message "Goodbye"} Note that the above is identical in function to simply calling (fail "Goodbye")
(ok-> start & forms)
Like some->, but with ok? instead of some? (i.e., short-circuits when it encounters a failure)
Like some->, but with ok? instead of some? (i.e., short-circuits when it encounters a failure)
(ok->> start & forms)
Like some->>, but with ok? instead of some? (i.e., short-circuits when it encounters a failure)
Like some->>, but with ok? instead of some? (i.e., short-circuits when it encounters a failure)
(try-all bindings return)
(try-all bindings return else)
Similar to attempt-all
but catches possible exceptions.
Wraps each arm of the binding in a try*
to treat them as Failures and short circuit.
Similar to `attempt-all` but catches possible exceptions. Wraps each arm of the binding in a `try*` to treat them as Failures and short circuit.
(when-failed arglist & body)
Use in combination with attempt-all
. If any binding in attempt-all
failed,
run the body given the failure/error as an argument.
Usage:
(attempt-all [_ (fail "Failure")] ; do something (when-failed [e] (print "ERROR:" (message e))))
Use in combination with `attempt-all`. If any binding in `attempt-all` failed, run the body given the failure/error as an argument. Usage: (attempt-all [_ (fail "Failure")] ; do something (when-failed [e] (print "ERROR:" (message e))))
(when-let-failed? [v-sym form] & failed-branches)
Inverse of when-let-ok?
(when-let-faild? [v (some-fn)] (prn "FAILED") (handle-failure v))
Returns the value in case of non-failure
Inverse of when-let-ok? (when-let-faild? [v (some-fn)] (prn "FAILED") (handle-failure v)) Returns the value in case of non-failure
(when-let-ok? [v-sym form] & ok-branches)
Analogous to if-let-ok? and when-let.
(when-let-ok? [v (some-fn)] (prn "WAS OK") (do-something v))
Returns the error in case of failure
Analogous to if-let-ok? and when-let. (when-let-ok? [v (some-fn)] (prn "WAS OK") (do-something v)) Returns the error in case of failure
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close