mirror of
https://github.com/janeczku/calibre-web
synced 2025-11-07 02:33:01 +00:00
Refactored exception logging
This commit is contained in:
@@ -88,10 +88,7 @@ def register_user_with_oauth(user=None):
|
||||
try:
|
||||
ub.session.commit()
|
||||
except Exception as e:
|
||||
if config.config_log_level == logger.logging.DEBUG:
|
||||
log.exception(e)
|
||||
else:
|
||||
log.error(e)
|
||||
log.debug_or_exception(e)
|
||||
ub.session.rollback()
|
||||
|
||||
|
||||
@@ -210,10 +207,7 @@ if ub.oauth_support:
|
||||
ub.session.add(oauth_entry)
|
||||
ub.session.commit()
|
||||
except Exception as e:
|
||||
if config.config_log_level == logger.logging.DEBUG:
|
||||
log.exception(e)
|
||||
else:
|
||||
log.error(e)
|
||||
log.debug_or_exception(e)
|
||||
ub.session.rollback()
|
||||
|
||||
# Disable Flask-Dance's default behavior for saving the OAuth token
|
||||
@@ -245,10 +239,7 @@ if ub.oauth_support:
|
||||
flash(_(u"Link to %(oauth)s Succeeded", oauth=provider_name), category="success")
|
||||
return redirect(url_for('web.profile'))
|
||||
except Exception as e:
|
||||
if config.config_log_level == logger.logging.DEBUG:
|
||||
log.exception(e)
|
||||
else:
|
||||
log.error(e)
|
||||
log.debug_or_exception(e)
|
||||
ub.session.rollback()
|
||||
else:
|
||||
flash(_(u"Login failed, No User Linked With OAuth Account"), category="error")
|
||||
@@ -295,10 +286,7 @@ if ub.oauth_support:
|
||||
logout_oauth_user()
|
||||
flash(_(u"Unlink to %(oauth)s Succeeded", oauth=oauth_check[provider]), category="success")
|
||||
except Exception as e:
|
||||
if config.config_log_level == logger.logging.DEBUG:
|
||||
log.exception(e)
|
||||
else:
|
||||
log.error(e)
|
||||
log.debug_or_exception(e)
|
||||
ub.session.rollback()
|
||||
flash(_(u"Unlink to %(oauth)s Failed", oauth=oauth_check[provider]), category="error")
|
||||
except NoResultFound:
|
||||
|
||||
Reference in New Issue
Block a user