Liking cljdoc? Tell your friends :D

clj-helpers.responses

Helper functions for returning unified responses.

Helper functions for returning unified responses.
raw docstring

as-errorclj/s

(as-error ctx)
(as-error type ctx)

Returns wrapped unified error result with the given value.

Returns wrapped unified `error` result with the given value.
sourceraw docstring

as-successclj/s

(as-success ctx)
(as-success type ctx)

Returns wrapped unified success result with the given value.

Returns wrapped unified `success` result with the given value.
sourceraw docstring

default-error-typeclj/s

Default unified error type.

Default unified `error` type.
sourceraw docstring

default-success-typeclj/s

Default unified success type.

Default unified `success` type.
sourceraw docstring

error-typesclj/s

Unified error types.

Unified `error` types.
sourceraw docstring

error?clj/s

(error? v)

Returns true when the given value is unified error result. Otherwise false.

Returns `true` when the given value is unified `error` result. Otherwise `false`.
sourceraw docstring

get-errorclj/s

(get-error v)

Returns unified error result.

Returns unified `error` result.
sourceraw docstring

get-error-contextclj/s

(get-error-context v)

Returns context of unified error result.

Returns `context` of unified `error` result.
sourceraw docstring

get-error-typeclj/s

(get-error-type v)

Returns type of unified error result.

Returns `type` of unified `error` result.
sourceraw docstring

get-successclj/s

(get-success v)

Returns unified success result.

Returns unified `success` result.
sourceraw docstring

get-success-contextclj/s

(get-success-context v)

Returns context of unified success result.

Returns `context` of unified `success` result.
sourceraw docstring

get-success-typeclj/s

(get-success-type v)

Returns type of unified success result.

Returns `type` of unified `success` result.
sourceraw docstring

if-errorcljmacro

(if-error bindings then)
(if-error bindings then else & oldform)

Works the same as if-success, but with inverted logic.

Works the same as `if-success`, but with inverted logic.
sourceraw docstring

if-successcljmacro

(if-success bindings then)
(if-success bindings then else & oldform)

Works the same as if-some or if-let, but checks for unified success result. And returns pair with result as [:type :ctx]. Where :type is keyword and :ctx is any value.

Examples: (if-success [[type ctx] (db/get-user-by-email "john@doe.com")] (println :success type ctx) (println :error type ctx))

If user exists: => :success :ok {:user/id 1, :user/email "john@doe.com"} If user not exists => :error :not-found {:user/login "john@doe.com"} If caught exception: => :error :fault #error{:cause class java.lang.Long cannot be cast to class java.lang.CharSequence ...}

Works the same as `if-some` or `if-let`, but checks for unified `success` result.
And returns pair with result as [:type :ctx].
Where :type is keyword and :ctx is any value.

Examples:
  (if-success [[type ctx] (db/get-user-by-email "john@doe.com")]
    (println :success type ctx)
    (println :error type ctx))

  If user exists:
    => :success :ok        {:user/id 1, :user/email "john@doe.com"}
  If user not exists
    => :error   :not-found {:user/login "john@doe.com"}
  If caught exception:
    => :error   :fault     #error{:cause class java.lang.Long cannot be cast to class java.lang.CharSequence ...}
sourceraw docstring

success-typesclj/s

Unified success types.

Unified `success` types.
sourceraw docstring

success?clj/s

(success? v)

Returns true when the given value is unified success result. Otherwise false.

Returns `true` when the given value is unified `success` result. Otherwise `false`.
sourceraw docstring

when-errorcljmacro

(when-error bindings & then)

Works the same as if-error, but without else branch.

Works the same as `if-error`, but without `else` branch.
sourceraw docstring

when-successcljmacro

(when-success bindings & then)

Works the same as if-success, but without else branch.

Works the same as `if-success`, but without `else` branch.
sourceraw docstring

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

× close