jws-backend/src/utils/error.ts
Methapon Metanipat 4da867cde1 refactor: helper function manual throw
This change is to prevent swagger to infer empty type from return type
2024-09-11 14:38:26 +07:00

18 lines
512 B
TypeScript

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