Skip to content

Commit

Permalink
Merge pull request bitpay#406 from isocolsky/ref/locked-err
Browse files Browse the repository at this point in the history
Return typed error on lock timeout
  • Loading branch information
matiu committed Nov 20, 2015
2 parents 9b5b6db + 524ed77 commit 06ec178
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/errors/errordefinitions.js
Expand Up @@ -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',
};
Expand Down
4 changes: 3 additions & 1 deletion lib/lock.js
Expand Up @@ -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) {
Expand All @@ -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();
Expand Down

0 comments on commit 06ec178

Please sign in to comment.