reitit

itaied 2024-03-06T11:52:23.350459Z

hey all, I'm using reitit in my clj app (using ring) how can I send the full stacktrace in the response and log it when an exception is thrown? currently only the name of the exception is thrown and it's missing a lot of debugging valuable data

def router
  (ring/ring-handler
   (ring/router
    ["/api" ...]
    {:data {:middleware [exception/exception-middleware]}})
   (ring/create-default-handler))

Ben Sless 2024-03-06T12:40:56.975579Z

Look at the exception middleware and its default case, that's just what you need

itaied 2024-03-06T12:59:19.336609Z

I have added the default middleware

{:data {:middleware [exception/exception-middleware]}})
but it return just a small portion of the exception (also documented like this)

Ben Sless 2024-03-06T13:54:15.475999Z

You want to use the create exception middleware and override the default handler https://github.com/metosin/reitit/blob/master/modules/reitit-middleware/src/reitit/ring/middleware/exception.clj#L119

👍 1