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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | 45x 45x 45x 42x 42x 42x 5x 5x 4x 4x 3x 3x 6x 6x 6x 3x 3x 8x 8x 8x 4x 4x 4x 4x | /**
* Custom Vitek errors
*/
export class VitekError extends Error {
constructor(message: string, public code?: string) {
super(message);
this.name = 'VitekError';
}
}
export class RouteError extends VitekError {
constructor(message: string, public route?: string) {
super(message, 'ROUTE_ERROR');
this.name = 'RouteError';
}
}
export class MiddlewareError extends VitekError {
constructor(message: string) {
super(message, 'MIDDLEWARE_ERROR');
this.name = 'MiddlewareError';
}
}
export class TypeGenerationError extends VitekError {
constructor(message: string) {
super(message, 'TYPE_GENERATION_ERROR');
this.name = 'TypeGenerationError';
}
}
/**
* Base HTTP error class with status code
*/
export class HttpError extends VitekError {
constructor(
message: string,
public statusCode: number = 500,
code?: string
) {
super(message, code);
this.name = 'HttpError';
}
}
/**
* 400 Bad Request error
*/
export class BadRequestError extends HttpError {
constructor(message: string = 'Bad request') {
super(message, 400, 'BAD_REQUEST');
this.name = 'BadRequestError';
}
}
/**
* 401 Unauthorized error
*/
export class UnauthorizedError extends HttpError {
constructor(message: string = 'Unauthorized') {
super(message, 401, 'UNAUTHORIZED');
this.name = 'UnauthorizedError';
}
}
/**
* 403 Forbidden error
*/
export class ForbiddenError extends HttpError {
constructor(message: string = 'Forbidden') {
super(message, 403, 'FORBIDDEN');
this.name = 'ForbiddenError';
}
}
/**
* 404 Not Found error
*/
export class NotFoundError extends HttpError {
constructor(message: string = 'Not found', public route?: string) {
super(message, 404, 'NOT_FOUND');
this.name = 'NotFoundError';
}
}
/**
* 409 Conflict error
*/
export class ConflictError extends HttpError {
constructor(message: string = 'Conflict') {
super(message, 409, 'CONFLICT');
this.name = 'ConflictError';
}
}
/**
* 422 Unprocessable Entity error (validation errors)
*/
export class ValidationError extends HttpError {
constructor(
message: string = 'Validation error',
public errors?: Record<string, string[]>
) {
super(message, 422, 'VALIDATION_ERROR');
this.name = 'ValidationError';
}
}
/**
* 429 Too Many Requests error
*/
export class TooManyRequestsError extends HttpError {
constructor(message: string = 'Too many requests') {
super(message, 429, 'TOO_MANY_REQUESTS');
this.name = 'TooManyRequestsError';
}
}
/**
* 500 Internal Server Error
*/
export class InternalServerError extends HttpError {
constructor(message: string = 'Internal server error') {
super(message, 500, 'INTERNAL_SERVER_ERROR');
this.name = 'InternalServerError';
}
}
|