Skip to content

Instantly share code, notes, and snippets.

@bennycode
Created June 27, 2018 12:55
Show Gist options
  • Select an option

  • Save bennycode/c5d0167886380e26d85ea9b2f1528aff to your computer and use it in GitHub Desktop.

Select an option

Save bennycode/c5d0167886380e26d85ea9b2f1528aff to your computer and use it in GitHub Desktop.
Custom Error
class NetworkError extends Error {
constructor(public message: string) {
super(message);
Object.setPrototypeOf(this, NetworkError.prototype);
this.name = 'NetworkError'; // Don't use "constructor.name" here because it won't work as expected when minifying the code ;)
this.stack = new Error().stack;
}
}
export {NetworkError};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment