TofuStack/src/lib/server/api/common/errors.ts

26 lines
726 B
TypeScript
Raw Normal View History

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') {
return new HTTPException(429, { message });
}
2024-05-25 06:02:26 +00:00
export function Forbidden(message: string = 'Forbidden') {
return new HTTPException(403, { message });
}
export function Unauthorized(message: string = 'Unauthorized') {
return new HTTPException(401, { message });
}
export function NotFound(message: string = 'Not Found') {
return new HTTPException(404, { message });
}
export function BadRequest(message: string = 'Bad Request') {
return new HTTPException(400, { message });
}
export function InternalError(message: string = 'Internal Error') {
return new HTTPException(500, { message });
}