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

@ -26,7 +26,7 @@ import {
} from "../services/permission";
import { filterStatus } from "../services/prisma";
import { connectOrDisconnect, connectOrNot } from "../utils/relation";
import { throwNotFound } from "../utils/error";
import { notFoundError } from "../utils/error";
if (!process.env.MINIO_BUCKET) {
throw Error("Require MinIO bucket.");
@ -298,7 +298,7 @@ export class BranchController extends Controller {
where: { id: branchId },
});
if (!record) return throwNotFound("Branch");
if (!record) throw notFoundError("Branch");
return record;
}
@ -540,7 +540,7 @@ export class BranchController extends Controller {
where: { id: branchId },
});
if (!record) return throwNotFound("Branch");
if (!record) throw notFoundError("Branch");
await permissionCheck(req.user, record);
@ -589,7 +589,7 @@ export class BranchFileController extends Controller {
include: branchRelationPermInclude(user),
where: { id },
});
if (!data) return throwNotFound("Branch");
if (!data) throw notFoundError("Branch");
await permissionCheck(user, data);
}