From 524ed773e2efa4e874268a3092c3dce9377d585b Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Fri, 20 Nov 2015 11:08:01 -0300 Subject: [PATCH] add WALLET_LOCKED error on lock timeout --- lib/errors/errordefinitions.js | 1 + lib/lock.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/errors/errordefinitions.js b/lib/errors/errordefinitions.js index b7015095812..f5e713f4c1a 100644 --- a/lib/errors/errordefinitions.js +++ b/lib/errors/errordefinitions.js @@ -29,6 +29,7 @@ var errors = { UPGRADE_NEEDED: 'Client app needs to be upgraded', WALLET_ALREADY_EXISTS: 'Wallet already exists', WALLET_FULL: 'Wallet full', + WALLET_LOCKED: 'Wallet is locked', WALLET_NOT_COMPLETE: 'Wallet is not complete', WALLET_NOT_FOUND: 'Wallet not found', }; diff --git a/lib/lock.js b/lib/lock.js index 255efb3ac5e..1ee3a65d906 100644 --- a/lib/lock.js +++ b/lib/lock.js @@ -7,6 +7,8 @@ log.disableColor(); var LocalLock = require('./locallock'); var RemoteLock = require('locker'); +var Errors = require('./errors/errordefinitions'); + function Lock(opts) { opts = opts || {}; if (opts.lockerServer) { @@ -29,7 +31,7 @@ Lock.prototype.runLocked = function(token, cb, task) { $.shouldBeDefined(token); this.lock.locked(token, 5 * 1000, 24 * 60 * 60 * 1000, function(err, release) { - if (err) return cb(new Error('Wallet is locked')); + if (err) return cb(Errors.WALLET_LOCKED); var _cb = function() { cb.apply(null, arguments); release();