Created
April 2, 2020 13:04
-
-
Save kluu1/e2a37b40c59d255456327a4e8ec33738 to your computer and use it in GitHub Desktop.
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 GeneralError extends Error { | |
| constructor(message) { | |
| super(); | |
| this.message = message; | |
| } | |
| getCode() { | |
| if (this instanceof BadRequest) { | |
| return 400; | |
| } if (this instanceof NotFound) { | |
| return 404; | |
| } | |
| return 500; | |
| } | |
| } | |
| class BadRequest extends GeneralError { } | |
| class NotFound extends GeneralError { } | |
| module.exports = { | |
| GeneralError, | |
| BadRequest, | |
| NotFound | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment