2024-09-10 02:25:16 +00:00
|
|
|
import { StatusCodes } from '$lib/constants/status-codes'
|
|
|
|
|
import { HTTPException } from 'hono/http-exception'
|
2024-07-21 19:05:48 +00:00
|
|
|
|
2024-09-10 02:25:16 +00:00
|
|
|
export function TooManyRequests(message = 'Too many requests') {
|
|
|
|
|
return new HTTPException(StatusCodes.TOO_MANY_REQUESTS, { message })
|
2024-07-21 19:05:48 +00:00
|
|
|
}
|
|
|
|
|
|
2024-09-10 02:25:16 +00:00
|
|
|
export function Forbidden(message = 'Forbidden') {
|
|
|
|
|
return new HTTPException(StatusCodes.FORBIDDEN, { message })
|
2024-07-21 19:05:48 +00:00
|
|
|
}
|
|
|
|
|
|
2024-09-10 02:25:16 +00:00
|
|
|
export function Unauthorized(message = 'Unauthorized') {
|
|
|
|
|
return new HTTPException(StatusCodes.UNAUTHORIZED, { message })
|
2024-07-21 19:05:48 +00:00
|
|
|
}
|
|
|
|
|
|
2024-09-10 02:25:16 +00:00
|
|
|
export function NotFound(message = 'Not Found') {
|
|
|
|
|
return new HTTPException(StatusCodes.NOT_FOUND, { message })
|
2024-07-21 19:05:48 +00:00
|
|
|
}
|
|
|
|
|
|
2024-09-10 02:25:16 +00:00
|
|
|
export function BadRequest(message = 'Bad Request') {
|
|
|
|
|
return new HTTPException(StatusCodes.BAD_REQUEST, { message })
|
2024-07-21 19:05:48 +00:00
|
|
|
}
|
|
|
|
|
|
2024-09-10 02:25:16 +00:00
|
|
|
export function InternalError(message = 'Internal Error') {
|
|
|
|
|
return new HTTPException(StatusCodes.INTERNAL_SERVER_ERROR, { message })
|
2024-07-21 19:05:48 +00:00
|
|
|
}
|