summaryrefslogtreecommitdiff
path: root/alot/db
diff options
context:
space:
mode:
authorJohannes Kulick <kulick@hildensia.de>2012-12-12 13:14:14 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2013-02-19 10:10:07 +0000
commitcfb5b34999961a7853b4bf2a25836e058a1555a6 (patch)
treea6441a503d346d9c64d1609b7af3d4f11cb9afb8 /alot/db
parentb0940e249b9add9a82c46aba3a30f0ae3289609d (diff)
give useful error message if key can't be found
Diffstat (limited to 'alot/db')
-rw-r--r--alot/db/envelope.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/alot/db/envelope.py b/alot/db/envelope.py
index 6d0f5311..2f1a53f2 100644
--- a/alot/db/envelope.py
+++ b/alot/db/envelope.py
@@ -212,12 +212,13 @@ class Envelope(object):
plaintext = crypto.email_as_string(unencrypted_msg)
logging.debug('encrypting plaintext: ' + plaintext)
- # TODO: find the correct key, or ask user
- key = crypto.get_key(self.encrypt_key)
try:
+ key = crypto.get_key(self.encrypt_key)
encrypted_str = crypto.encrypt(plaintext, key)
except gpgme.GpgmeError as e:
+ if e.code == gpgme.ERR_INV_VALUE:
+ raise GPGProblem("Can not find key to encrypt.")
raise GPGProblem(str(e))
outer_msg = MIMEMultipart('encrypted',