diff --git a/lib/box.js b/lib/box.js index b71c985..27f1c72 100644 --- a/lib/box.js +++ b/lib/box.js @@ -50,11 +50,11 @@ Box.prototype.execute = function (app) { this.isSync ? this.done(this.fn.call(proxy, get)) : this.fn.call(proxy, get, function (error, val) { - if (error) return app._raise(self.path, error) + if (error) return self.error(app, error) self.done(val) }) } catch (e) { - app._raise(this.path, e) + this.error(app, e) } } @@ -68,6 +68,11 @@ Box.prototype.done = function (val) { this.callbacks = null } +Box.prototype.error = function (app, err) { + this.callbacks = null + app._raise(this.path, err) +} + Box.prototype.onready = function (cb) { this.callbacks = this.callbacks || [] this.callbacks.push(cb)