blob: 349c920fdd2bf44a03d243127f3724bf9446c75a [file] [log] [blame]
(function() {
var Reply;
Reply = (function() {
Reply.ERROR = 'ERROR';
Reply.OK = 'OK';
function Reply(type, value) {
this.type = type;
this.value = value;
}
Reply.prototype.isError = function() {
return this.type === Reply.ERROR;
};
Reply.prototype.toError = function() {
if (!this.isError()) {
throw new Error('toError() cannot be called for non-errors');
}
return new Error(this.value);
};
return Reply;
})();
module.exports = Reply;
}).call(this);