You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by wa...@apache.org on 2026/04/14 20:05:24 UTC
(tooling-trusted-releases) 01/01: Only show exception detail in dev environments
This is an automated email from the ASF dual-hosted git repository.
wave pushed a commit to branch only-show-execption-detail-in-dev
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git
commit 3591398b4e9febb76da65958330f2d1a3e7f2cc4
Author: Dave Fisher <da...@comcast.net>
AuthorDate: Tue Apr 14 13:04:27 2026 -0700
Only show exception detail in dev environments
---
atr/blueprints/api.py | 5 ++++-
atr/server.py | 16 ++++++++++++----
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/atr/blueprints/api.py b/atr/blueprints/api.py
index facc1374..62a8545d 100644
--- a/atr/blueprints/api.py
+++ b/atr/blueprints/api.py
@@ -31,6 +31,7 @@ import quart_schema
import werkzeug.exceptions as exceptions
import atr.blueprints.common as common
+import atr.config as config
import atr.log as log
import atr.web as web
@@ -155,7 +156,9 @@ async def _handle_asfquart_exception(err: base.ASFQuartException) -> tuple[quart
@_BLUEPRINT.errorhandler(Exception)
async def _handle_generic_exception(err: Exception) -> tuple[quart.Response, int]:
- return _json_error(str(err), 500)
+ if config.is_dev_environment():
+ return _json_error(str(err), 500)
+ return _json_error("Exception", 500)
@_BLUEPRINT.errorhandler(exceptions.HTTPException)
diff --git a/atr/server.py b/atr/server.py
index deea0eab..8dbe80a9 100644
--- a/atr/server.py
+++ b/atr/server.py
@@ -977,7 +977,9 @@ def _register_routes(app: base.QuartApp) -> None: # noqa: C901
if quart.request.path.startswith("/api"):
status_code = getattr(error, "code", 500) if isinstance(error, Exception) else 500
- return quart.jsonify({"error": str(error)}), status_code
+ if config.is_dev_environment():
+ return quart.jsonify({"error": str(error)}), status_code
+ return quart.jsonify({"error": "Exception"}), status_code
exc_info = (type(error), error, error.__traceback__)
log.error("Unhandled exception", exc_info=exc_info)
@@ -988,19 +990,25 @@ def _register_routes(app: base.QuartApp) -> None: # noqa: C901
traceback=traceback.format_exc(),
status_code=500,
), 500
- return await template.render("error.html", error=str(error), status_code=500), 500
+ return await template.render("error.html", error="Exception", status_code=500), 500
@app.errorhandler(base.ASFQuartException)
async def handle_asfquart_exception(error: base.ASFQuartException) -> Any:
# TODO: Figure out why pyright doesn't know about this attribute
if quart.request.path.startswith("/api"):
errorcode = getattr(error, "errorcode", 500)
- return quart.jsonify({"error": str(error)}), errorcode
+ if config.is_dev_environment():
+ return quart.jsonify({"error": str(error)}), errorcode
+ return quart.jsonify({"error": "Exception"}), errorcode
if not hasattr(error, "errorcode"):
errorcode = 500
else:
errorcode = getattr(error, "errorcode")
- return await template.render("error.html", error=str(error), status_code=errorcode), errorcode
+ exc_info = (type(error), error, error.__traceback__)
+ log.error("Unhandled exception", exc_info=exc_info)
+ if config.is_dev_environment():
+ return await template.render("error.html", error=str(error), status_code=errorcode), errorcode
+ return await template.render("error.html", error="Exception", status_code=errorcode), errorcode
# Add a global error handler for payload too large which will normally be handled in front in httpd server
@app.errorhandler(413)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org