Liking cljdoc? Tell your friends :D

unirate.errors

Error model for the UniRate API client.

Every error the client raises is a clojure.lang.ExceptionInfo (created with ex-info) carrying a :unirate/error-type keyword in its ex-data. A caller can therefore catch clojure.lang.ExceptionInfo to handle any failure, or branch on the error type:

(try
  (unirate.client/get-rate client "USD" "EUR")
  (catch clojure.lang.ExceptionInfo e
    (case (:unirate/error-type (ex-data e))
      :authentication  (handle-bad-key)
      :rate-limit      (back-off)
      :invalid-currency (warn)
      (rethrow e))))

The keyword set is the Clojure equivalent of the typed exception hierarchy in the other UniRate clients:

error-typeHTTPmeaning
:invalid-date400malformed date / invalid request params
:authentication401missing or invalid API key
:invalid-currency404unknown currency or no data available
:rate-limit429request quota exceeded
:api*any other non-2xx (403 Pro-gate, 503, ...)
:uniratetransport / parse / generic failure (base)
Error model for the UniRate API client.

Every error the client raises is a `clojure.lang.ExceptionInfo` (created with
`ex-info`) carrying a `:unirate/error-type` keyword in its `ex-data`. A caller
can therefore catch `clojure.lang.ExceptionInfo` to handle any failure, or
branch on the error type:

    (try
      (unirate.client/get-rate client "USD" "EUR")
      (catch clojure.lang.ExceptionInfo e
        (case (:unirate/error-type (ex-data e))
          :authentication  (handle-bad-key)
          :rate-limit      (back-off)
          :invalid-currency (warn)
          (rethrow e))))

The keyword set is the Clojure equivalent of the typed exception hierarchy in
the other UniRate clients:

| error-type        | HTTP | meaning                                    |
|-------------------|------|--------------------------------------------|
| :invalid-date     | 400  | malformed date / invalid request params    |
| :authentication   | 401  | missing or invalid API key                 |
| :invalid-currency | 404  | unknown currency or no data available      |
| :rate-limit       | 429  | request quota exceeded                      |
| :api              | *    | any other non-2xx (403 Pro-gate, 503, ...) |
| :unirate          | —    | transport / parse / generic failure (base) |
raw docstring

api-errorclj

(api-error status body)

Any other non-success HTTP response — most notably HTTP 403 on the Pro-gated historical endpoints when called with a free-tier key, and HTTP 503 when the service is unavailable. The originating :status and (trimmed) :response-body are carried in the ex-data.

Any other non-success HTTP response — most notably HTTP 403 on the Pro-gated
historical endpoints when called with a free-tier key, and HTTP 503 when the
service is unavailable. The originating `:status` and (trimmed)
`:response-body` are carried in the `ex-data`.
sourceraw docstring

authentication-errorclj

(authentication-error)

HTTP 401 — the API key is missing or invalid.

HTTP 401 — the API key is missing or invalid.
sourceraw docstring

invalid-currency-errorclj

(invalid-currency-error)

HTTP 404 — an unknown currency code or no data available.

HTTP 404 — an unknown currency code or no data available.
sourceraw docstring

invalid-date-errorclj

(invalid-date-error)

HTTP 400 — a malformed date or other invalid request parameters.

HTTP 400 — a malformed date or other invalid request parameters.
sourceraw docstring

map-statusclj

(map-status status body)

Map an HTTP status code (and response body) to the appropriate error.

Map an HTTP status code (and response body) to the appropriate error.
sourceraw docstring

rate-limit-errorclj

(rate-limit-error)

HTTP 429 — the account has exceeded its request quota.

HTTP 429 — the account has exceeded its request quota.
sourceraw docstring

unirate-errorclj

(unirate-error msg)
(unirate-error msg data)

The base error: a transport, parse, or otherwise generic failure. All other errors share the same ex-data shape but with a more specific :unirate/error-type.

The base error: a transport, parse, or otherwise generic failure.
All other errors share the same `ex-data` shape but with a more specific
`:unirate/error-type`.
sourceraw docstring

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