Skip to content

Instantly share code, notes, and snippets.

@rmlopes
Last active June 28, 2018 09:55
Show Gist options
  • Save rmlopes/6f1d668e8f45532407d37ee3744d96f2 to your computer and use it in GitHub Desktop.
Save rmlopes/6f1d668e8f45532407d37ee3744d96f2 to your computer and use it in GitHub Desktop.
An example of using flask abort to raise internal server errors with pyEve
# In case of an internal server error, flask abort will send an html reponse, which is not in line with a REST API.
# _handle_internal_error returns the typical pyEve json error response:
def _handle_internal_error(message, code=500):
abort(make_response(
jsonify(_status = "ERR",
_error = {'code':code, 'message':message}),
code))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment