Closed adambrown closed 8 years ago
You can throw an HttpErrorCodeWithBody
which accepts the message
(reason string), code
(status code), and root cause exception same as HttpErrorCode
class, but adds additional body
parameter of type Any
which can be a string (text/html
) or an object that will be turned into JSON (application/json
)
fixed in 0.13.0
to be released in the next few hours.
Kovert doesn't seem to allow returning an application/json body with a 400 error even though HTTP allows and actually strongly recommends this. Sometimes on an invalid request way more details are needed than just an http code and message.
Here is the relevant part of http spec:
Note that all caps SHOULD include and entity containing an explanation of the error.
A good example of where this is needed and used effectively is card validation error codes with Stripe:
https://stripe.com/docs/api/java#errors