Skip to content

Commit

Permalink
fix: make cause a nonenumerable property
Browse files Browse the repository at this point in the history
Users should explicitly request cause or fullStack in order to retrieve causes.
  • Loading branch information
jdpnielsen committed Sep 14, 2020
1 parent 025c774 commit 74ae474
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/cerror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ export class CError extends Error {
}

if (cause) {
this.cause = cause;
Object.defineProperty(this, 'cause', {
value: cause,
enumerable: false,
});

if (!options?.skipCauseMessage) {
this.message += `: ${cause.message}`;
}
Expand Down

0 comments on commit 74ae474

Please sign in to comment.