Skip to content

Instantly share code, notes, and snippets.

@salvar-labs
Last active April 8, 2023 03:17
Show Gist options
  • Save salvar-labs/4e77778de2c37e5f49fbcb20146454c7 to your computer and use it in GitHub Desktop.
Save salvar-labs/4e77778de2c37e5f49fbcb20146454c7 to your computer and use it in GitHub Desktop.
Correctly creating an custom Error class in TypeScript
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