Created
May 16, 2018 15:44
-
-
Save datatypevoid/d52ba0a616df9fefa278b18cc2ebd55c to your computer and use it in GitHub Desktop.
Generic TypeScript Error class
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
/* | |
* Imports | |
*/ | |
/* | |
* Structures | |
*/ | |
abstract class BaseError<T> extends Error { | |
protected readonly _type: T; | |
public get type (): T { | |
return this._type; | |
} | |
protected constructor (type: T, message: string) { | |
super(message); | |
this._type = type; | |
(Object as any).setPrototypeOf(this, BaseError.prototype); | |
} | |
} | |
/* | |
* Exports | |
*/ | |
export { | |
BaseError | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment