Skip to content

Instantly share code, notes, and snippets.

@ThomasAribart
Last active May 10, 2020 21:42
Show Gist options
  • Save ThomasAribart/d23c5d0c564cf4b4a808a6f8f9ad78e2 to your computer and use it in GitHub Desktop.
Save ThomasAribart/d23c5d0c564cf4b4a808a6f8f9ad78e2 to your computer and use it in GitHub Desktop.
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