Skip to content

Commit bcbb096

Browse files
committed
Do not directly set Error properties.
Fixes #231
1 parent 192dbe7 commit bcbb096

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

index.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,16 @@ function createErrorType(code, message, baseClass) {
597597

598598
// Attach constructor and set default properties
599599
CustomError.prototype = new (baseClass || Error)();
600-
CustomError.prototype.constructor = CustomError;
601-
CustomError.prototype.name = "Error [" + code + "]";
600+
Object.defineProperties(CustomError.prototype, {
601+
constructor: {
602+
value: CustomError,
603+
enumerable: false,
604+
},
605+
name: {
606+
value: "Error [" + code + "]",
607+
enumerable: false,
608+
},
609+
});
602610
return CustomError;
603611
}
604612

0 commit comments

Comments
 (0)