Last active
April 8, 2023 03:17
-
-
Save salvar-labs/4e77778de2c37e5f49fbcb20146454c7 to your computer and use it in GitHub Desktop.
Correctly creating an custom Error class in TypeScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomError extends Error { | |
__proto__ = Error | |
constructor(message: string) { | |
super(message); | |
Object.setPrototypeOf(this, CustomError.prototype); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment