Fixing exception logging with Timber

This commit is contained in:
Philip Whitehouse 2017-03-18 17:31:40 +00:00 committed by Vincent Breitmoser
parent 31e41e7b02
commit 62a8bae494
4 changed files with 9 additions and 10 deletions

View file

@ -92,7 +92,7 @@ public class LocalKeyStore {
mKeyStore = store; mKeyStore = store;
mKeyStoreFile = file; mKeyStoreFile = file;
} catch (Exception e) { } catch (Exception e) {
Timber.e("Failed to initialize local key store", e); Timber.e(e, "Failed to initialize local key store");
// Use of the local key store is effectively disabled. // Use of the local key store is effectively disabled.
mKeyStore = null; mKeyStore = null;
mKeyStoreFile = null; mKeyStoreFile = null;

View file

@ -387,7 +387,7 @@ class ImapConnection {
} }
private void handlePermanentXoauth2Failure(NegativeImapResponseException e) throws AuthenticationFailedException { private void handlePermanentXoauth2Failure(NegativeImapResponseException e) throws AuthenticationFailedException {
Timber.v(e, "Permanent failure during XOAUTH2", e); Timber.v(e, "Permanent failure during XOAUTH2");
throw new AuthenticationFailedException(e.getMessage(), e); throw new AuthenticationFailedException(e.getMessage(), e);
} }
@ -397,13 +397,13 @@ class ImapConnection {
//if a token was invalid before use (e.g. due to expiry). But we don't //if a token was invalid before use (e.g. due to expiry). But we don't
//This is the intended behaviour per AccountManager //This is the intended behaviour per AccountManager
Timber.v(e, "Temporary failure - retrying with new token", e); Timber.v(e, "Temporary failure - retrying with new token");
try { try {
attemptXOAuth2(); attemptXOAuth2();
} catch (NegativeImapResponseException e2) { } catch (NegativeImapResponseException e2) {
//Okay, we failed on a new token. //Okay, we failed on a new token.
//Invalidate the token anyway but assume it's permanent. //Invalidate the token anyway but assume it's permanent.
Timber.v(e, "Authentication exception for new token, permanent error assumed", e); Timber.v(e, "Authentication exception for new token, permanent error assumed");
oauthTokenProvider.invalidateToken(settings.getUsername()); oauthTokenProvider.invalidateToken(settings.getUsername());
handlePermanentXoauth2Failure(e2); handlePermanentXoauth2Failure(e2);
} }
@ -581,7 +581,7 @@ class ImapConnection {
} }
} catch (IOException e) { } catch (IOException e) {
close(); close();
Timber.e(e, "Error enabling compression", e); Timber.e(e, "Error enabling compression");
} }
} }
@ -632,7 +632,7 @@ class ImapConnection {
try { try {
listResponses = executeSimpleCommand(Commands.LIST + " \"\" \"\""); listResponses = executeSimpleCommand(Commands.LIST + " \"\" \"\"");
} catch (NegativeImapResponseException e) { } catch (NegativeImapResponseException e) {
Timber.d(e, "Error getting path delimiter using LIST command", e); Timber.d(e, "Error getting path delimiter using LIST command");
return; return;
} }

View file

@ -638,7 +638,7 @@ class ImapFolderPusher extends ImapFolder {
pushReceiver.messagesRemoved(ImapFolderPusher.this, messages); pushReceiver.messagesRemoved(ImapFolderPusher.this, messages);
} catch (Exception e) { } catch (Exception e) {
Timber.e("Cannot remove EXPUNGEd messages", e); Timber.e("Cannot remove EXPUNGEd messages");
} }
} }

View file

@ -859,7 +859,7 @@ public class SmtpTransport extends Transport {
//if a token was invalid before use (e.g. due to expiry). But we don't //if a token was invalid before use (e.g. due to expiry). But we don't
//This is the intended behaviour per AccountManager //This is the intended behaviour per AccountManager
Timber.v("Authentication exception, re-trying with new token", negativeResponseFromOldToken); Timber.v(negativeResponseFromOldToken, "Authentication exception, re-trying with new token");
try { try {
attemptXoauth2(username); attemptXoauth2(username);
} catch (NegativeSmtpReplyException negativeResponseFromNewToken) { } catch (NegativeSmtpReplyException negativeResponseFromNewToken) {
@ -869,8 +869,7 @@ public class SmtpTransport extends Transport {
//Okay, we failed on a new token. //Okay, we failed on a new token.
//Invalidate the token anyway but assume it's permanent. //Invalidate the token anyway but assume it's permanent.
Timber.v("Authentication exception for new token, permanent error assumed", Timber.v(negativeResponseFromNewToken, "Authentication exception for new token, permanent error assumed");
negativeResponseFromNewToken);
oauthTokenProvider.invalidateToken(username); oauthTokenProvider.invalidateToken(username);