From fc436af1349807cc26f1069258b09247e6f648f2 Mon Sep 17 00:00:00 2001 From: dandds Date: Thu, 9 Aug 2018 11:48:33 -0400 Subject: [PATCH 1/2] log errors in error handlers --- atst/domain/exceptions.py | 4 +++- atst/routes/errors.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/atst/domain/exceptions.py b/atst/domain/exceptions.py index b92e64c1..ec574232 100644 --- a/atst/domain/exceptions.py +++ b/atst/domain/exceptions.py @@ -27,4 +27,6 @@ class UnauthorizedError(Exception): class UnauthenticatedError(Exception): - pass + @property + def message(self): + return str(self) diff --git a/atst/routes/errors.py b/atst/routes/errors.py index 0d0211b8..e9dcafcf 100644 --- a/atst/routes/errors.py +++ b/atst/routes/errors.py @@ -8,12 +8,14 @@ def make_error_pages(app): @app.errorhandler(exceptions.UnauthorizedError) # pylint: disable=unused-variable def not_found(e): + app.logger.error(e.message) return render_template("not_found.html"), 404 @app.errorhandler(exceptions.UnauthenticatedError) # pylint: disable=unused-variable def unauthorized(e): + app.logger.error(e.message) return render_template('unauthorized.html'), 401 return app From 3f01d455bb440cee7b1d1e9791e3b94af3315ef0 Mon Sep 17 00:00:00 2001 From: dandds Date: Thu, 9 Aug 2018 11:57:37 -0400 Subject: [PATCH 2/2] better name, text for unauthenticated page --- atst/routes/errors.py | 2 +- templates/{unauthorized.html => unauthenticated.html} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename templates/{unauthorized.html => unauthenticated.html} (83%) diff --git a/atst/routes/errors.py b/atst/routes/errors.py index e9dcafcf..5fdac3d1 100644 --- a/atst/routes/errors.py +++ b/atst/routes/errors.py @@ -16,6 +16,6 @@ def make_error_pages(app): # pylint: disable=unused-variable def unauthorized(e): app.logger.error(e.message) - return render_template('unauthorized.html'), 401 + return render_template('unauthenticated.html'), 401 return app diff --git a/templates/unauthorized.html b/templates/unauthenticated.html similarity index 83% rename from templates/unauthorized.html rename to templates/unauthenticated.html index efaa3b95..8fabbdf9 100644 --- a/templates/unauthorized.html +++ b/templates/unauthenticated.html @@ -4,7 +4,7 @@
-

Unauthorized

+

Log in Failed