summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Kulick <kulick@hildensia.de>2012-12-18 11:30:08 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2013-02-19 10:10:08 +0000
commitedf87f1ea8d3a3a76235649b852f9486ddd76726 (patch)
tree43ac7634dd71f14b913f82b26e525bdbb27a887c
parentb9a57a6f9840fe16c920148eae4451997abdde64 (diff)
better error messages
also the error catchings are mostly moved to crypto.py whcih makes everything else a little bit cleaner
-rw-r--r--alot/commands/envelope.py8
-rw-r--r--alot/crypto.py3
2 files changed, 3 insertions, 8 deletions
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py
index b462e0bc..000d734f 100644
--- a/alot/commands/envelope.py
+++ b/alot/commands/envelope.py
@@ -485,9 +485,7 @@ class EncryptCommand(Command):
tmp_key = crypto.get_key(keyid)
del envelope.encrypt_keys[crypto.hash_key(tmp_key)]
except gpgme.GpgmeError as e:
- if e.code == gpgme.ERR_INV_VALUE:
- raise GPGProblem("Can not find key to remove.")
- raise GPGProblem(str(e))
+ ui.notify(e.message, priority='error')
if not envelope.encrypt_keys:
envelope.encrypt = False
ui.current_buffer.rebuild()
@@ -519,10 +517,6 @@ class EncryptCommand(Command):
keys[crypto.hash_key(tmp_key)] = tmp_key
envelope.encrypt_keys.update(keys)
- except gpgme.GpgmeError as e:
- if e.code == gpgme.ERR_INV_VALUE or e.code == gpgme.ERR_EOF:
- ui.notify("Can not find key to encrypt.", priority='error')
- raise GPGProblem(str(e))
except GPGProblem, e:
ui.notify(e.message, priority='error')
return
diff --git a/alot/crypto.py b/alot/crypto.py
index 9000d15b..97449c78 100644
--- a/alot/crypto.py
+++ b/alot/crypto.py
@@ -122,9 +122,10 @@ def get_key(keyid):
except gpgme.GpgmeError as e:
if e.code == gpgme.ERR_AMBIGUOUS_NAME:
# Deferred import to avoid a circular import dependency
- from alot.db.errors import GPGProblem
raise GPGProblem(("More than one key found matching this filter."
" Please be more specific (use a key ID like 4AC8EE1D)."))
+ elif e.code == gpgme.ERR_INV_VALUE or e.code == gpgme.ERR_EOF:
+ raise GPGProblem("Can not find key for " + keyid)
else:
raise e
return key