Shared machinery for building this library's ErrorData (SPEC §5.1/§7) and converting it into a thrown ex-info at each action boundary. Used by clj-infisical.{credentials,auth,secrets} -- extracted because all three independently reimplemented the same 'is this an error, and if so throw it' check, and auth/secrets independently reimplemented the same safe-JSON-parse-for-a-response-body helper.
Shared machinery for building this library's ErrorData (SPEC §5.1/§7)
and converting it into a thrown ex-info at each action boundary. Used by
clj-infisical.{credentials,auth,secrets} -- extracted because all three
independently reimplemented the same 'is this an error, and if so throw
it' check, and auth/secrets independently reimplemented the same
safe-JSON-parse-for-a-response-body helper.(error-data type status body parsed)Builds an ErrorData map (SPEC §5.1): :type plus the :status/:body/:parsed fields every HTTP-originated error branch in auth/secrets carries.
Builds an ErrorData map (SPEC §5.1): :type plus the :status/:body/:parsed fields every HTTP-originated error branch in auth/secrets carries.
(error? result)True only when :type is a keyword. ErrorData's :type is always one of
this library's own :clj-infisical/... keywords, constructed by our own
code -- never derived from parsed JSON (clojure.data.json/read-str never
produces keyword values). A bare (:type result) truthiness check isn't
safe here: Secret is an open passthrough of whatever Infisical returns
(SPEC §5.1), and Infisical's real secret objects carry their own field
literally named "type" (e.g. "shared"/"personal"), which becomes
:type "shared" after keywordizing -- a string value that would
otherwise be misread as ErrorData and thrown on an entirely successful
fetch.
True only when :type is a keyword. ErrorData's :type is always one of this library's own :clj-infisical/... keywords, constructed by our own code -- never derived from parsed JSON (clojure.data.json/read-str never produces keyword values). A bare `(:type result)` truthiness check isn't safe here: Secret is an open passthrough of whatever Infisical returns (SPEC §5.1), and Infisical's real secret objects carry their own field literally named "type" (e.g. "shared"/"personal"), which becomes `:type "shared"` after keywordizing -- a *string* value that would otherwise be misread as ErrorData and thrown on an entirely successful fetch.
(parse-json body)clojure.data.json/read-str, returning nil instead of throwing when body isn't valid JSON -- an HTTP response body is never guaranteed to be JSON (proxies, gateways, etc. can return anything).
clojure.data.json/read-str, returning nil instead of throwing when body isn't valid JSON -- an HTTP response body is never guaranteed to be JSON (proxies, gateways, etc. can return anything).
(unwrap! message-prefix result)Given a calculation's result (either good Data, or ErrorData per SPEC §5.1), returns it unchanged, or throws an ex-info carrying it if it's an error. The one place resolve-credentials!/login!/fetch-secret! turn a returned ErrorData into a thrown one.
Given a calculation's result (either good Data, or ErrorData per SPEC §5.1), returns it unchanged, or throws an ex-info carrying it if it's an error. The one place resolve-credentials!/login!/fetch-secret! turn a returned ErrorData into a thrown one.
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 |