Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | 8x 14x 14x 14x 8x 8x 8x 10x 10x 8x 8x 4x 4x 8x 8x | export class APIError extends Error {
readonly statusCode: number;
constructor(message: string, statusCode: number) {
super(message);
this.statusCode = statusCode;
this.name = "APIError";
}
}
/**
* Error tied to the 400 status code,
* for use when a DAO discovers invalid data
*/
export class InvalidDataError extends APIError {
constructor(message: string) {
super(message, 400);
this.name = "InvalidDataError";
}
}
/**
* Error tied to the 401 status code,
* for use when a user is not authorized to perform the request
*/
export class UnauthorizedError extends APIError {
constructor(message: string) {
super(message, 401);
this.name = "UnauthorizedError";
}
}
/**
* Error tied to the 404 status code,
* for use when there is no such resource (or no such *parent* resource)
*/
export class NotFoundError extends APIError {
constructor(message: string) {
super(message, 404);
this.name = "NotFoundError";
}
}
/**
* Error tied to the 409 status code,
* for use when there exists something with identical primary identifiers
*/
export class ConflictError extends APIError {
constructor(message: string) {
super(message, 409);
this.name = "ConflictError";
}
}
/**
* Error tied to the 422 status code,
* for use when e.g. there is no such dumpster type
*/
export class InvalidKeyError extends APIError {
constructor(message: string) {
super(message, 422);
this.name = "InvalidKeyError";
}
}
/**
* Error tied to the 422 status code,
* for use when you don't know exactly what went wrong,
* but you *do* know that it's probably the client's fault
* (thus, the API is unable to process this particular request)
*/
export class UnknownError extends APIError {
constructor(message: string) {
super(message, 422);
this.name = "UnknownError";
}
}
/**
* Error tied to the 500 status code,
* for use when you don't know exactly what went wrong,
* and you're pretty sure it's *your* fault
*/
export class ServerError extends APIError {
constructor(message: string) {
super(message, 500);
this.name = "ServerError";
}
}
|