From f23dee936969a833277b35a9f4c78e5f7de0a015 Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Thu, 14 Nov 2013 21:39:20 +0100 Subject: [PATCH] minor cleanup on error handlers --- src/js/dao/email-dao.js | 5 +++-- src/js/dao/publickey-dao.js | 9 +-------- src/js/util/download.js | 4 ++-- test/new-unit/email-dao-test.js | 3 ++- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/js/dao/email-dao.js b/src/js/dao/email-dao.js index 65b5997..5ed25d9 100644 --- a/src/js/dao/email-dao.js +++ b/src/js/dao/email-dao.js @@ -324,8 +324,9 @@ define(function(require) { uuid = email.body.substr(index + consts.verificationUrlPrefix.length, consts.verificationUuidLength); self._keychain.verifyPublicKey(uuid, function(err) { if (err) { - console.error('Unable to verify public key: ' + err.errMsg); - localCallback(); + callback({ + errMsg: 'Verifying your public key failed: ' + err.errMsg + }); return; } diff --git a/src/js/dao/publickey-dao.js b/src/js/dao/publickey-dao.js index ace7709..d9177d6 100644 --- a/src/js/dao/publickey-dao.js +++ b/src/js/dao/publickey-dao.js @@ -14,14 +14,7 @@ define(function() { this._restDao.get({ uri: uri, type: 'text' - }, function(err) { - if (err) { - callback(err); - return; - } - - callback(); - }); + }, callback); }; /** diff --git a/src/js/util/download.js b/src/js/util/download.js index 5f674fa..c195740 100644 --- a/src/js/util/download.js +++ b/src/js/util/download.js @@ -28,9 +28,9 @@ define(function() { } function onError(e) { - console.error(e); callback({ - errMsg: 'Error exporting keypair to file!' + errMsg: 'Error exporting keypair to file!', + err: e }); } diff --git a/test/new-unit/email-dao-test.js b/test/new-unit/email-dao-test.js index bed4674..cc2ae82 100644 --- a/test/new-unit/email-dao-test.js +++ b/test/new-unit/email-dao-test.js @@ -696,6 +696,7 @@ define(function(require) { done(); }); }); + it('should not mark verification mails read if verification fails', function(done) { devicestorageStub.listItems.yields(null, [verificationMail]); keychainStub.verifyPublicKey.yields({ @@ -707,7 +708,7 @@ define(function(require) { offset: 0, num: 1 }, function(err) { - expect(err).to.not.exist; + expect(err).to.exist; expect(devicestorageStub.listItems.calledOnce).to.be.true; expect(keychainStub.verifyPublicKey.calledOnce).to.be.true; done();