Skip to content

Commit

Permalink
Fix second issue
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Jan 3, 2025
1 parent 9da9a38 commit c7754f7
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class NonError extends Error {
}
}

const commonProperties = [
const errorProperties = [
{
property: 'name',
enumerable: false,
Expand Down Expand Up @@ -127,14 +127,16 @@ const destroyCircular = ({
to[key] = '[Circular]';
}

for (const {property, enumerable} of commonProperties) {
if (from[property] !== undefined && from[property] !== null) {
Object.defineProperty(to, property, {
value: isErrorLike(from[property]) ? continueDestroyCircular(from[property]) : from[property],
enumerable: forceEnumerable ? true : enumerable,
configurable: true,
writable: true,
});
if (serialize || to instanceof Error) {
for (const {property, enumerable} of errorProperties) {
if (from[property] !== undefined && from[property] !== null) {
Object.defineProperty(to, property, {
value: isErrorLike(from[property]) ? continueDestroyCircular(from[property]) : from[property],
enumerable: forceEnumerable ? true : enumerable,
configurable: true,
writable: true,
});
}
}
}

Expand Down

0 comments on commit c7754f7

Please sign in to comment.