Closed yayitswei closed 10 years ago
Hi, did you find an answer for this problem? I have the same issue. Thanks
Sorry for the delay. You can actually give an error handler to the middleware, and the 0.4.0
release from a few hours ago juste made it easier. Here is an exemple:
(wrap-restful-format handler :request-error-handler
(fn [exception _ request]
(cond
(instance? com.fasterxml.jackson.core.JsonParseException exception)
{:status 400 :body "Error parsing JSON body"}
:else {:status 500 :body "Unknown error"})))
Does that answer your problem? If it does, I'll add something like this to the README...
Thanks for getting replying. This answers the problem.
When given invalid json,
wrap_format_params
fails with an exception,com.fasterxml.jackson.core.JsonParseException: Unexpected character ...
. What's a good way to handle this exception and return a 400 status code?