curious about error handling. I am doing something like this:
(defn log-error-response [response]
(let [throwable (:cognitect.aws.client/throwable response)
category (:cognitect.anomalies/category response)
default-message "An error occurred during AWS client invocation."
message (or (:message response) default-message)]
(when category
(let [e (ex-info message response)]
(if throwable
(log/error throwable message)
(log/error e message))))
response))
Is this good enough to "catch 'em all"?I tossed throwable
in there because I saw for instance, when an unbound var was referenced in the body of a call to aws/invoke, I got one of these:
{:cognitect.anomalies/category :cognitect.anomalies/fault,
:cognitect.aws.client/throwable #error {
:cause "Don't know how to write JSON of class clojure.lang.Var$Unbound"
which contains no :message
key. I suppose the other question is where I can rely on :message
to be there.