Liking cljdoc? Tell your friends :D

failjure.core


assert-nil?clj/s

source

assert-not-empty?clj/s

source

assert-not-nil?clj/s

source

assert-number?clj/s

source

assert-some?clj/s

source

assert-withclj/s

(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)
sourceraw docstring

attempt->clj/smacro

(attempt-> start)
(attempt-> start form)
(attempt-> start form & forms)

Deprecated. Use ok-> instead.

Deprecated. Use ok-> instead.
source (clj)source (cljs)raw docstring

attempt->>clj/smacro

(attempt->> start)
(attempt->> start form)
(attempt->> start form & forms)

Deprecated. Use ok->> instead.

Deprecated. Use ok->> instead.
source (clj)source (cljs)raw docstring

attempt-allclj/smacro

(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"

source (clj)source (cljs)raw docstring

else*clj/s

(else* else-part result)
source

failclj/s

(fail msg)
(fail msg & fmt-parts)
source

Failurecljs

source

HasFailedclj/s≠protocol

failed?clj/s

(failed? self)

messageclj/s

(message self)
source

if-failedclj/smacrodeprecated

(if-failed arglist & body)

DEPRECATED: Use when-failed instead

DEPRECATED: Use when-failed instead
source (clj)source (cljs)raw docstring

if-let-failed?clj/smacro

(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"
source (clj)source (cljs)raw docstring

if-let-ok?clj/smacro

(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")
source (clj)source (cljs)raw docstring

ok->clj/smacro

(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)
source (clj)source (cljs)raw docstring

ok->>clj/smacro

(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)
source (clj)source (cljs)raw docstring

ok?clj/s

(ok? v)
source

try*clj/smacro

(try* & body)
source (clj)source (cljs)

try-allclj/smacro

(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.
source (clj)source (cljs)raw docstring

try-fnclj/s

(try-fn body-fn)
source

when-failedclj/smacro

(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))))
source (clj)source (cljs)raw docstring

when-let-failed?clj/smacro

(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
source (clj)source (cljs)raw docstring

when-let-ok?clj/smacro

(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
source (clj)source (cljs)raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close