diff --git a/packages/node_modules/pouchdb-errors/src/index.js b/packages/node_modules/pouchdb-errors/src/index.js index 1aad79dd59..a863551aaf 100644 --- a/packages/node_modules/pouchdb-errors/src/index.js +++ b/packages/node_modules/pouchdb-errors/src/index.js @@ -44,26 +44,13 @@ var MISSING_STUB = new PouchError(412, 'missing_stub', 'A pre-existing attachmen var INVALID_URL = new PouchError(413, 'invalid_url', 'Provided URL is invalid'); function createError(error, reason) { - function CustomPouchError(reason) { - // inherit error properties from our parent error manually - // so as to allow proper JSON parsing. - var names = Object.getOwnPropertyNames(error); - for (var i = 0, len = names.length; i < len; i++) { - if (typeof error[names[i]] !== 'function') { - this[names[i]] = error[names[i]]; - } - } - - if (this.stack === undefined) { - this.stack = (new Error()).stack; - } - - if (reason !== undefined) { - this.reason = reason; - } + // inherit error properties from our parent error manually + // so as to allow proper JSON parsing. + var err = new PouchError(error.status, error.name, error.message); + if (reason !== undefined) { + err.reason = reason; } - CustomPouchError.prototype = PouchError.prototype; - return new CustomPouchError(reason); + return err; } function generateErrorFromResponse(err) {