diff --git a/lib/errors/errordefinitions.js b/lib/errors/errordefinitions.js index b701509..f5e713f 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 255efb3..1ee3a65 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();