From 3ee94d58e0f24d3812ac59ef91b43e24856db45b Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Thu, 14 Jan 2016 11:35:11 -0500 Subject: [PATCH 1/2] catch Exception and properly log errors --- lib/galaxy/webapps/galaxy/controllers/user.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/webapps/galaxy/controllers/user.py b/lib/galaxy/webapps/galaxy/controllers/user.py index 041e298a920..2936d0866c9 100644 --- a/lib/galaxy/webapps/galaxy/controllers/user.py +++ b/lib/galaxy/webapps/galaxy/controllers/user.py @@ -788,7 +788,8 @@ class User( BaseUIController, UsesFormDefinitionsMixin, CreatesUsersMixin, Creat subject = 'Join Mailing List' try: util.send_mail( frm, to, subject, body, trans.app.config ) - except: + except Exception, e: + log.error( 'Subscribing to the mailing list has failed.', e ) error = "Now logged in as " + user.email + ". However, subscribing to the mailing list has failed." if not error and not is_admin: # The handle_user_login() method has a call to the history_set_default_permissions() method @@ -847,7 +848,8 @@ class User( BaseUIController, UsesFormDefinitionsMixin, CreatesUsersMixin, Creat try: util.send_mail( frm, to, subject, body, trans.app.config ) return True - except: + except Exception, e: + log.error( 'Unable to send the activation email.', e ) return False def prepare_activation_link( self, trans, email ): From 12445a0524510dbafffa4c7908e243f70c55f154 Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Thu, 14 Jan 2016 12:53:23 -0500 Subject: [PATCH 2/2] use log.exception instead of log.error to retain the stacktrace --- lib/galaxy/webapps/galaxy/controllers/user.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/webapps/galaxy/controllers/user.py b/lib/galaxy/webapps/galaxy/controllers/user.py index 2936d0866c9..a2dc790c9c5 100644 --- a/lib/galaxy/webapps/galaxy/controllers/user.py +++ b/lib/galaxy/webapps/galaxy/controllers/user.py @@ -788,8 +788,8 @@ class User( BaseUIController, UsesFormDefinitionsMixin, CreatesUsersMixin, Creat subject = 'Join Mailing List' try: util.send_mail( frm, to, subject, body, trans.app.config ) - except Exception, e: - log.error( 'Subscribing to the mailing list has failed.', e ) + except Exception: + log.exception( 'Subscribing to the mailing list has failed.' ) error = "Now logged in as " + user.email + ". However, subscribing to the mailing list has failed." if not error and not is_admin: # The handle_user_login() method has a call to the history_set_default_permissions() method @@ -848,8 +848,8 @@ class User( BaseUIController, UsesFormDefinitionsMixin, CreatesUsersMixin, Creat try: util.send_mail( frm, to, subject, body, trans.app.config ) return True - except Exception, e: - log.error( 'Unable to send the activation email.', e ) + except Exception: + log.exception( 'Unable to send the activation email.' ) return False def prepare_activation_link( self, trans, email ):