in lib/parallel-write.js [106:136]
function magicCopyError(origError) {
// TODO sub classing error... ...
var freshError = new Error(origError.message);
// Copying the stack is valid...
freshError.stack = origError.stack;
// copy keys before making message & stack enumerable
Object.keys(origError).forEach(function copyProp(k) {
var value = origError[k];
if (typeof value === 'object' && value !== null) {
freshError[k] = magicCopy(value);
} else {
freshError[k] = value;
}
});
Object.defineProperty(freshError, 'message', {
value: freshError.message,
enumerable: true,
configurable: true
});
Object.defineProperty(freshError, 'stack', {
value: freshError.stack,
enumerable: true,
configurable: true
});
return freshError;
}