diff --git a/docs/en_US/release_notes_4_2.rst b/docs/en_US/release_notes_4_2.rst index 577569217..8e73411db 100644 --- a/docs/en_US/release_notes_4_2.rst +++ b/docs/en_US/release_notes_4_2.rst @@ -47,4 +47,5 @@ Bug fixes | `Bug #3935 `_ - Ensure that grant wizard should list down functions for EPAS server running with no-redwood-compat mode. | `Bug #3941 `_ - Dashboard graph optimization. | `Bug #3954 `_ - Remove Python 2.6 code that's now obsolete. -| `Bug #3955 `_ - Expose the bind address in the Docker container via PGADMIN_BIND_ADDRESS. \ No newline at end of file +| `Bug #3955 `_ - Expose the bind address in the Docker container via PGADMIN_BIND_ADDRESS. +| `Bug #3961 `_ - Exclude HTTPExceptions from the all_exception_handler as they should be returned as-is. \ No newline at end of file diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py index c1b2589d6..ff465d721 100644 --- a/web/pgadmin/__init__.py +++ b/web/pgadmin/__init__.py @@ -16,6 +16,7 @@ from collections import defaultdict from importlib import import_module from flask import Flask, abort, request, current_app, session, url_for +from werkzeug.exceptions import HTTPException from flask_babelex import Babel, gettext from flask_login import user_logged_in, user_logged_out from flask_mail import Mail @@ -669,6 +670,14 @@ def create_app(app_name=None): current_app.logger.error(e, exc_info=True) return internal_server_error(errormsg=str(e)) + # Exclude HTTPexception from above handler (all_exception_handler) + # HTTPException are user defined exceptions and those should be returned + # as is + @app.errorhandler(HTTPException) + def http_exception_handler(e): + current_app.logger.error(e, exc_info=True) + return e + ########################################################################## # All done! ##########################################################################