Last active
May 19, 2020 00:49
-
-
Save Sytten/a22f424d5ff0a6626bc97efbd0a1edc1 to your computer and use it in GitHub Desktop.
failing-revenge-error-handling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@bp.app_errorhandler(Exception) | |
def handle_exception(e): | |
if type(e) == json.JSONDecodeError: | |
message=f"Unexpected JSON object: {e.doc}" | |
elif type(e) == APIException: | |
message=f"APIError due to API answer: {e.response}" | |
else: | |
message=f"Unexpected error: {type(e).__name__}" | |
import traceback | |
traceback.print_stack() | |
return render_template("error.html", message=message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment