Skip to content

Commit e1bb478

Browse files
sybrenstuvellepture
authored andcommitted
Log exception traceback. (lepture#281)
This is especially important in an "except Exception" block, as it can catch any exception from any source and for any reason.
1 parent d1c1946 commit e1bb478

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

flask_oauthlib/provider/oauth2.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,13 @@ def decorated(*args, **kwargs):
390390
kwargs['scopes'] = scopes
391391
kwargs.update(credentials)
392392
except oauth2.FatalClientError as e:
393-
log.debug('Fatal client error %r', e)
393+
log.debug('Fatal client error %r', e, exc_info=True)
394394
return redirect(e.in_uri(self.error_uri))
395395
except oauth2.OAuth2Error as e:
396-
log.debug('OAuth2Error: %r', e)
396+
log.debug('OAuth2Error: %r', e, exc_info=True)
397397
return redirect(e.in_uri(redirect_uri))
398398
except Exception as e:
399-
log.warning('Exception caught while processing request, %s.' % e)
399+
log.warning('Exception caught while processing request, %s.' % e, exc_info=True)
400400
return redirect(add_params_to_uri(
401401
self.error_uri, {'error': str(e) }
402402
))
@@ -409,13 +409,13 @@ def decorated(*args, **kwargs):
409409
try:
410410
rv = f(*args, **kwargs)
411411
except oauth2.FatalClientError as e:
412-
log.debug('Fatal client error %r', e)
412+
log.debug('Fatal client error %r', e, exc_info=True)
413413
return redirect(e.in_uri(self.error_uri))
414414
except oauth2.OAuth2Error as e:
415-
log.debug('OAuth2Error: %r', e)
415+
log.debug('OAuth2Error: %r', e, exc_info=True)
416416
return redirect(e.in_uri(redirect_uri))
417417
except Exception as e:
418-
log.warning('Exception caught while processing request, %s.' % e)
418+
log.warning('Exception caught while processing request, %s.' % e, exc_info=True)
419419
return redirect(add_params_to_uri(
420420
self.error_uri, {'error': str(e) }
421421
))
@@ -454,13 +454,13 @@ def confirm_authorization_request(self):
454454
log.debug('Authorization successful.')
455455
return create_response(*ret)
456456
except oauth2.FatalClientError as e:
457-
log.debug('Fatal client error %r', e)
457+
log.debug('Fatal client error %r', e, exc_info=True)
458458
return redirect(e.in_uri(self.error_uri))
459459
except oauth2.OAuth2Error as e:
460-
log.debug('OAuth2Error: %r', e)
460+
log.debug('OAuth2Error: %r', e, exc_info=True)
461461
return redirect(e.in_uri(redirect_uri or self.error_uri))
462462
except Exception as e:
463-
log.warning('Exception caught while processing request, %s.' % e)
463+
log.warning('Exception caught while processing request, %s.' % e, exc_info=True)
464464
return redirect(add_params_to_uri(
465465
self.error_uri, {'error': str(e) }
466466
))
@@ -627,7 +627,7 @@ def authenticate_client(self, request, *args, **kwargs):
627627
client_id = to_unicode(client_id, 'utf-8')
628628
client_secret = to_unicode(client_secret, 'utf-8')
629629
except Exception as e:
630-
log.debug('Authenticate client failed with exception: %r', e)
630+
log.warning('Authenticate client failed with exception: %r', e, exc_info=True)
631631
return False
632632
else:
633633
client_id = request.client_id

0 commit comments

Comments
 (0)