Skip to content

Instantly share code, notes, and snippets.

@jbis9051
Created December 8, 2020 16:56
Show Gist options
  • Save jbis9051/15ff9ed0b18df879a0cb548722d6caa7 to your computer and use it in GitHub Desktop.
Save jbis9051/15ff9ed0b18df879a0cb548722d6caa7 to your computer and use it in GitHub Desktop.
class APIError extends Error {
public readonly name: string;
public readonly httpCode: HttpStatusCode;
constructor(name: string, httpCode: HttpStatusCode, description: string) {
super(description);
this.name = name;
this.httpCode = httpCode;
Error.captureStackTrace(this);
}
}
enum HttpStatusCode {
OK = 200,
BAD_REQUEST = 400,
NOT_FOUND = 404,
INTERNAL_SERVER = 500,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment