From a3aec1bd838dc53c96937d54474bcb6da865a9f1 Mon Sep 17 00:00:00 2001 From: Aadit M Shah Date: Tue, 6 Feb 2024 13:51:00 +0530 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Use=20the=20new=20`defineV?= =?UTF-8?q?alue`=20function=20in=20`setName`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This changes prevents repetition and also provides better type safety. --- src/exceptions.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/exceptions.ts b/src/exceptions.ts index 08b3f53..9d8c73f 100644 --- a/src/exceptions.ts +++ b/src/exceptions.ts @@ -1,3 +1,5 @@ +import { defineValue } from "./expression.js"; + export interface ErrorOptions { cause?: unknown; } @@ -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 }); } }