Liking cljdoc? Tell your friends :D

Anomaly

Blockether anomalies - standardized error categories based on Cognitect anomalies.

Installation

Add the following dependency to your deps.edn:

{:deps {com.blockether/anomaly {:mvn/version "1.0.1"}}}

Usage

(require '[com.blockether.anomaly.core :as anomaly])

;; Throw standardized errors
(anomaly/not-found! "User not found" {:user-id 123})
(anomaly/forbidden! "Access denied")
(anomaly/incorrect! "Invalid email format" {:field :email})

;; Create anomaly maps without throwing
(anomaly/anomaly ::anomaly/not-found "Resource missing" {:id 456})

;; Check HTTP status
(anomaly/http-status {::anomaly/category ::anomaly/forbidden}) ;; => 403

;; Predicates
(anomaly/anomaly? some-map)
(anomaly/client-error? anomaly-map)
(anomaly/server-error? anomaly-map)

Anomaly Categories

CategoryHTTPDescription
::unavailable503Service temporarily unavailable, retry later
::interrupted500Operation was interrupted
::incorrect400Bad request, invalid input
::forbidden403Not authorized to perform this action
::unauthorized401Authentication required
::not-found404Resource not found
::conflict409Conflict with current state (e.g., duplicate)
::fault500Internal server error
::busy503Server is busy, retry later
::unsupported501Operation not supported

Can you improve this documentation?Edit on GitHub

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