MichaelDrogalis / dire

Erlang-style supervisor error handling for Clojure
483 stars 19 forks source link

Cannot handle error in buddy-sign #38

Open neverfox opened 6 years ago

neverfox commented 6 years ago

I cannot handle the ExceptionInfo that is thrown from this function in buddy.sign.jwt, forcing me to use a regular try/catch:

(defn unsign
  ([message pkey] (unsign message pkey {}))
  ([message pkey opts]
   (try
     (-> (jws/unsign message pkey opts)
         (codecs/bytes->str)
         (json/parse-string true)
         (validate-claims opts))
     (catch com.fasterxml.jackson.core.JsonParseException e
       (throw (ex-info "Message seems corrupt or manipulated."
                       {:type :validation :cause :signature}))))))
(require '[buddy.sign.jwt :as jwt])

;; never handles
(with-handler! #'jwt/unsign
  clojure.lang.ExceptionInfo
  (fn [e & args]
    (raise :jwt-error)))

Is it possibly because an exception is being caught and rethrown?