Improve application level exception handling for unhandled exceptions.

This commit is contained in:
Aditya Toshniwal 2019-01-23 12:49:05 +05:30 committed by Akshay Joshi
parent fcfe0929d3
commit 1f29859040
2 changed files with 9 additions and 2 deletions

View File

@ -34,6 +34,8 @@ from pgadmin.utils.session import create_session_interface, pga_unauthorised
from pgadmin.utils.versioned_template_loader import VersionedTemplateLoader
from datetime import timedelta
from pgadmin.setup import get_version, set_version
from pgadmin.utils.ajax import internal_server_error
# If script is running under python3, it will not have the xrange function
# defined
@ -662,6 +664,11 @@ def create_app(app_name=None):
'current_blueprint': current_blueprint
}
@app.errorhandler(Exception)
def all_exception_handler(e):
current_app.logger.error(e, exc_info=True)
return internal_server_error(errormsg=str(e))
##########################################################################
# All done!
##########################################################################

View File

@ -438,8 +438,8 @@ define('pgadmin.datagrid', [
err.errormsg
);
} catch (e) {
alertify.alert(
e.statusText, gettext('Query Tool Initialize Error')
alertify.alert(gettext('Query Tool Initialize Error'),
e.statusText
);
}
});