Skip to content

Commit

Permalink
♻️ Use the new defineValue function in setName
Browse files Browse the repository at this point in the history
This changes prevents repetition and also provides better type safety.
  • Loading branch information
aaditmshah committed Feb 6, 2024
1 parent 34c9fe0 commit a3aec1b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/exceptions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { defineValue } from "./expression.js";

export interface ErrorOptions {
cause?: unknown;
}
Expand All @@ -16,10 +18,6 @@ export abstract class Exception extends Error {
}

protected setName(name: string): void {
Object.defineProperty(this, "name", {
value: name,
enumerable: false,
configurable: true,
});
defineValue(this, "name", name, { enumerable: false });
}
}

0 comments on commit a3aec1b

Please sign in to comment.