Fork me on GitHub
#pedestal
<
2022-05-06
>
tomekw09:05:18

What's the idiomatic way to catch all exceptions using error-dispatch so I could display the full stack trace in the dev mode and custom error page in prod? :thinking_face:

tomekw10:05:15

(def error-handler-intc
  (error/error-dispatch [ctx ex]
                        :else (assoc ctx :response (ok (app-layout [:div
                                                                    [:h2 (ex-message ex)]
                                                                    [:pre (with-out-str (trace/print-stack-trace ex))]])))))
?

ddeaguiar12:05:49

@U030521UZ1N I’d use a separate error handling interceptor for dev as opposed to using env-based dispatch. For example, Pedestal’s http://pedestal.io/api/pedestal.service/io.pedestal.http.html#var-dev-interceptors will return a response with the stack trace. You can include them in your dev interceptors.

👍 1