Instead of overriding one error page at a time like this:
@bottle.error(404)
def not_found_error(error):
return {"error": "resource not found"}
I would like to override *all* error pages, in order to prevent Bottle from sending HTML:
@bottle.error()
def error_handler(error):
return {"error": "unexpected error"}
And then override specific status codes after that, to provide more information:
@bottle.error(500)
def server_error(error):
return {"error": "server error, please try again later"}
This doesn't work however, since calling Bottle.error with no arguments defaults to code 500.
Is there any convenient way to override the default error handler, so I can prevent my JSON API from returning HTML?