From 68386e67abd5e35e539ef1b8851a85b1c0ed2b6e Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Mon, 13 Sep 2021 16:29:10 -0700 Subject: [PATCH] feat: show nice error page in prod --- superset/views/base.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/superset/views/base.py b/superset/views/base.py index 61bd312fb6019..30ab632f26573 100644 --- a/superset/views/base.py +++ b/superset/views/base.py @@ -437,6 +437,10 @@ def show_http_exception(ex: HTTPException) -> FlaskResponse: @superset_app.errorhandler(CommandException) def show_command_errors(ex: CommandException) -> FlaskResponse: logger.warning(ex) + if "text/html" in request.accept_mimetypes and not config["DEBUG"]: + path = resource_filename("superset", "static/assets/500.html") + return send_file(path), 500 + extra = ex.normalized_messages() if isinstance(ex, CommandInvalidError) else {} return json_errors_response( errors=[ @@ -455,6 +459,10 @@ def show_command_errors(ex: CommandException) -> FlaskResponse: @superset_app.errorhandler(Exception) def show_unexpected_exception(ex: Exception) -> FlaskResponse: logger.exception(ex) + if "text/html" in request.accept_mimetypes and not config["DEBUG"]: + path = resource_filename("superset", "static/assets/500.html") + return send_file(path), 500 + return json_errors_response( errors=[ SupersetError(