refactor: helper function manual throw

This change is to prevent swagger to infer empty type from return type
This commit is contained in:
Methapon Metanipat 2024-09-11 14:38:26 +07:00
parent 5b9472b466
commit 4da867cde1
4 changed files with 22 additions and 22 deletions

View file

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