jws-backend/src/utils/error.ts
2024-09-10 16:41:40 +07:00

18 lines
515 B
TypeScript

import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status";
export function throwRelationError(name: string) {
throw new HttpError(
HttpStatus.BAD_REQUEST,
`${name} cannot be found.`,
`relation${name.replaceAll(" ", "")}NotFound`,
);
}
export function throwNotFound(name: string) {
throw new HttpError(
HttpStatus.BAD_REQUEST,
`${name} cannot be found.`,
`${name.charAt(0).toLowerCase() + name.replaceAll(" ", "").slice(1)}NotFound`,
);
}