I have a bottle server that returns HTTPErrors as such:
return HTTPError(400, "Object already exists with that name")
When I receive this response in the browser, I'd like to be able to pick out the error message given. As it is right now I can see the error message in the response's responseText
field, but it's buried in an HTML string that I'd rather not parse if I don't have to.
Is there any way I can specifically set the error message in Bottle so I can pick it out in JSON in the browser?
HTTPError
uses a predefined HTML template to build the body of the response. Instead of usingHTTPError
you can useresponse
with the appropriate status code and body.