Add BoxError.toPlainObject

This commit is contained in:
Girish Ramakrishnan
2019-09-05 21:10:55 -07:00
parent 99e63ffc3f
commit a18a620847
2 changed files with 12 additions and 7 deletions
+6 -1
View File
@@ -3,7 +3,8 @@
'use strict';
const assert = require('assert'),
util = require('util');
util = require('util'),
_ = require('underscore');
exports = module.exports = BoxError;
@@ -36,3 +37,7 @@ BoxError.CONFLICT = 'Conflict';
BoxError.EXTERNAL_ERROR = 'External Error';
BoxError.INTERNAL_ERROR = 'Internal Error';
BoxError.NOT_FOUND = 'Not found';
BoxError.prototype.toPlainObject = function () {
return _.extend({}, { message: this.message, reason: this.reason }, this.details);
};