Last active
May 10, 2020 21:42
-
-
Save ThomasAribart/d23c5d0c564cf4b4a808a6f8f9ad78e2 to your computer and use it in GitHub Desktop.
This file contains 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
const defaultStatusCodes = new Set([400, 401, 403, 404, 422, 500, 502, 504]); | |
class CustomError extends Error { | |
constructor(statusCode: number, { key, message, payload }) { | |
super(message); | |
if (!defaultStatusCodes.has(statusCode)) { | |
throw new Error(`No integration response associated with statusCode ${statusCode}`); | |
} | |
... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment