diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-04-13 18:13:34 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-04-13 18:13:34 +0200 |
commit | 9b1a4a456a35fc78ee0562c861967406cb5c6050 (patch) | |
tree | ae420b70495232d1cce0c32836d46a458ae196e2 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service | |
parent | 194523303fd3a11f7a36f0312a4ce1605557be67 (diff) | |
download | open-keychain-9b1a4a456a35fc78ee0562c861967406cb5c6050.tar.gz open-keychain-9b1a4a456a35fc78ee0562c861967406cb5c6050.tar.bz2 open-keychain-9b1a4a456a35fc78ee0562c861967406cb5c6050.zip |
Handle new exceptions in KeychainIntentService
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index e2f4e9d95..1e0da7cb9 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -862,15 +862,36 @@ public class KeychainIntentService extends IntentService if (this.mIsCanceled) { return; } + // TODO: Implement a better exception handling here // contextualize the exception, if necessary + String message; if (e instanceof PgpGeneralMsgIdException) { e = ((PgpGeneralMsgIdException) e).getContextualized(this); + message = e.getMessage(); + } else if (e instanceof PgpSignEncrypt.KeyExtractionException) { + message = getString(R.string.error_could_not_extract_private_key); + } else if (e instanceof PgpSignEncrypt.NoPassphraseException) { + message = getString(R.string.error_no_signature_passphrase); + } else if (e instanceof PgpSignEncrypt.NoSigningKeyException) { + message = getString(R.string.error_signature_failed); + } else if (e instanceof PgpDecryptVerify.InvalidDataException) { + message = getString(R.string.error_invalid_data); + } else if (e instanceof PgpDecryptVerify.KeyExtractionException) { + message = getString(R.string.error_could_not_extract_private_key); + } else if (e instanceof PgpDecryptVerify.WrongPassphraseException) { + message = getString(R.string.error_wrong_passphrase); + } else if (e instanceof PgpDecryptVerify.NoSecretKeyException) { + message = getString(R.string.error_no_secret_key_found); + } else if (e instanceof PgpDecryptVerify.IntegrityCheckFailedException) { + message = getString(R.string.error_integrity_check_failed); + } else { + message = e.getMessage(); } + Log.e(Constants.TAG, "KeychainIntentService Exception: ", e); - e.printStackTrace(); Bundle data = new Bundle(); - data.putString(KeychainIntentServiceHandler.DATA_ERROR, e.getMessage()); + data.putString(KeychainIntentServiceHandler.DATA_ERROR, message); sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_EXCEPTION, null, data); } |