Structured error handling using Cognitect anomalies pattern.
Anomaly categories map to Stripe/HTTP errors:
Structured error handling using Cognitect anomalies pattern. Anomaly categories map to Stripe/HTTP errors: - :cognitect.anomalies/busy - 429 Rate limit - :cognitect.anomalies/unavailable - 5xx Server errors, connection errors - :cognitect.anomalies/interrupted - Request timeout - :cognitect.anomalies/incorrect - 400 Invalid request, card errors - :cognitect.anomalies/forbidden - 401/403 Auth errors - :cognitect.anomalies/not-found - 404 Resource not found - :cognitect.anomalies/conflict - 409 Idempotency errors - :cognitect.anomalies/fault - Unexpected errors, parse failures
(anomaly? response)Returns true if response contains an anomaly category.
Returns true if response contains an anomaly category.
(build-anomaly status body request-id)Builds an anomaly map from HTTP status, response body, and request-id.
Builds an anomaly map from HTTP status, response body, and request-id.
(category response)Returns the anomaly category keyword, or nil if not an anomaly.
Returns the anomaly category keyword, or nil if not an anomaly.
(decline-code response)Returns the card decline code (e.g. "insufficient_funds"), or nil.
Returns the card decline code (e.g. "insufficient_funds"), or nil.
(exception->anomaly e)Converts a Java exception to an anomaly map.
Converts a Java exception to an anomaly map.
Maps HTTP status codes to anomaly categories.
Maps HTTP status codes to anomaly categories.
(message response)Returns the error message.
Returns the error message.
(parse-stripe-error body)Parses a Stripe error response body into namespaced keys. Returns nil if no :error key in body.
Parses a Stripe error response body into namespaced keys. Returns nil if no :error key in body.
(retryable? response)Returns true if the anomaly is potentially retryable. Categories :busy, :unavailable, and :interrupted may succeed on retry.
Returns true if the anomaly is potentially retryable. Categories :busy, :unavailable, and :interrupted may succeed on retry.
(status->category status)Returns anomaly category for HTTP status, with fallback based on range.
Returns anomaly category for HTTP status, with fallback based on range.
(stripe-error-code response)Returns the Stripe error code string (e.g. "card_declined"), or nil.
Returns the Stripe error code string (e.g. "card_declined"), or nil.
(stripe-error-type response)Returns the Stripe error type string (e.g. "card_error"), or nil.
Returns the Stripe error type string (e.g. "card_error"), or nil.
Maps Stripe error types to anomaly categories. Takes precedence over HTTP status when available.
Maps Stripe error types to anomaly categories. Takes precedence over HTTP status when available.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |