Make GPG key import errors more verbose

This commit is contained in:
Roberto Rosario
2012-01-25 02:17:17 -04:00
parent e7a2aed6a0
commit 4fe7803ff1
2 changed files with 10 additions and 3 deletions

View File

@@ -341,4 +341,4 @@ class GPG(object):
if import_result: if import_result:
return Key.get(self, import_result.fingerprints[0], secret=False) return Key.get(self, import_result.fingerprints[0], secret=False)
raise KeyImportError raise KeyImportError(import_result.results[0].get('text', 'Unknown error'))

View File

@@ -37,8 +37,15 @@ def key_receive(request, key_id):
key = gpg.import_key(keys_dict[key_id].key) key = gpg.import_key(keys_dict[key_id].key)
messages.success(request, _(u'Key: %s, imported successfully.') % key) messages.success(request, _(u'Key: %s, imported successfully.') % key)
return HttpResponseRedirect(next) return HttpResponseRedirect(next)
except (KeyImportError, KeyError, TypeError): except (KeyImportError, KeyError, TypeError), e:
messages.error(request, _(u'Unable to import key id: %s') % key_id) messages.error(
request,
_(u'Unable to import key id: %(key_id)s; %(error)s') %
{
'key_id': key_id,
'error': e,
}
)
return HttpResponseRedirect(previous) return HttpResponseRedirect(previous)
return render_to_response('generic_confirm.html', { return render_to_response('generic_confirm.html', {