refactor: throw common error with util function instead

This commit is contained in:
Methapon Metanipat 2024-10-03 09:41:47 +07:00
parent 68f9dc203e
commit 4de0e1da87
12 changed files with 67 additions and 142 deletions

View file

@ -16,3 +16,11 @@ export function notFoundError(name: string) {
`${name.charAt(0).toLowerCase() + name.replaceAll(" ", "").slice(1)}NotFound`,
);
}
export function isUsedError(name: string) {
return new HttpError(
HttpStatus.PRECONDITION_FAILED,
`${name} cannot be found.`,
`${name.charAt(0).toLowerCase() + name.replaceAll(" ", "").slice(1)}IsUsed`,
);
}