Skip to content
16 changes: 9 additions & 7 deletions packages/node_modules/pouchdb-errors/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ function createError(error, reason) {
pouchError[name] = error[name];
}

try {
void pouchError.stack;
} catch (e) {
// Silently ignore inaccessible stack
}

Comment thread
Mayankaggarwal8055 marked this conversation as resolved.
Outdated
if (reason !== undefined) {
pouchError.reason = reason;
}
Expand All @@ -70,9 +76,9 @@ function createError(error, reason) {
function generateErrorFromResponse(err) {

if (typeof err !== 'object') {
var data = err;
err = UNKNOWN_ERROR;
err.data = data;
const newErr = Object.assign({}, UNKNOWN_ERROR); // Clone to avoid mutation
newErr.data = err;
err = newErr;
Comment thread
Mayankaggarwal8055 marked this conversation as resolved.
Outdated
}

if ('error' in err && err.error === 'conflict') {
Expand All @@ -92,10 +98,6 @@ function generateErrorFromResponse(err) {
err.message = err.message || err.reason;
}

if (!('stack' in err)) {
err.stack = (new Error()).stack;
}

Comment thread
SourceR85 marked this conversation as resolved.
return err;
}

Expand Down