2024-06-26 17:15:38 +00:00
|
|
|
import { StatusCodes } from '$lib/constants/status-codes';
|
2024-05-25 06:02:26 +00:00
|
|
|
import { HTTPException } from 'hono/http-exception';
|
|
|
|
|
|
2024-06-25 02:45:00 +00:00
|
|
|
export function TooManyRequests(message: string = 'Too many requests') {
|
2024-06-26 17:15:38 +00:00
|
|
|
return new HTTPException(StatusCodes.TOO_MANY_REQUESTS, { message });
|
2024-06-25 02:45:00 +00:00
|
|
|
}
|
|
|
|
|
|
2024-05-25 06:02:26 +00:00
|
|
|
export function Forbidden(message: string = 'Forbidden') {
|
2024-06-26 17:15:38 +00:00
|
|
|
return new HTTPException(StatusCodes.FORBIDDEN, { message });
|
2024-05-25 06:02:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function Unauthorized(message: string = 'Unauthorized') {
|
2024-06-26 17:15:38 +00:00
|
|
|
return new HTTPException(StatusCodes.UNAUTHORIZED, { message });
|
2024-05-25 06:02:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function NotFound(message: string = 'Not Found') {
|
2024-06-26 17:15:38 +00:00
|
|
|
return new HTTPException(StatusCodes.NOT_FOUND, { message });
|
2024-05-25 06:02:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function BadRequest(message: string = 'Bad Request') {
|
2024-06-26 17:15:38 +00:00
|
|
|
return new HTTPException(StatusCodes.BAD_REQUEST, { message });
|
2024-05-25 06:02:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function InternalError(message: string = 'Internal Error') {
|
2024-06-26 17:15:38 +00:00
|
|
|
return new HTTPException(StatusCodes.INTERNAL_SERVER_ERROR, { message });
|
2024-05-25 06:02:26 +00:00
|
|
|
}
|