Fork me on GitHub
#pedestal
<
2021-03-19
>
lucian30321:03:42

i have an error interceptor that works well in capturing exceptions thrown directly from another interceptor, in this case (add-corpus-document) below. but it doesn’t capture exceptions thrown from a function (add-document) that’s called indirectly through map below by that interceptor. in that case, it seems to continue w/ the interceptor chain until another directly called interceptor throws a different exception which would have the one below as its cause. this doesn’t make any sense. why would an exception get handled differently directly in an interceptor but not in the functions it calls?

(defn add-document
  [id request file]
  (throw (ex-info "nope, this doesn't directly trigger the error interceptor"
                  {:show-user true
                   :type      :validation}))

(defn add-corpus-document
  [request]
  ;; the same (throw) call above would work just fine here directly in the interceptor
  (ring-response/response (map #(add-document 0 0 %) (:multipart-params request))))

lucian30323:03:45

nevermind, seems to be because of the lazy map call above