refactor: throw common error with util function instead
This commit is contained in:
parent
68f9dc203e
commit
4de0e1da87
12 changed files with 67 additions and 142 deletions
|
|
@ -26,7 +26,7 @@ import {
|
|||
} from "../services/permission";
|
||||
import { filterStatus } from "../services/prisma";
|
||||
import { connectOrDisconnect, connectOrNot, whereAddressQuery } from "../utils/relation";
|
||||
import { notFoundError, relationError } from "../utils/error";
|
||||
import { isUsedError, notFoundError, relationError } from "../utils/error";
|
||||
|
||||
if (!process.env.MINIO_BUCKET) {
|
||||
throw Error("Require MinIO bucket.");
|
||||
|
|
@ -547,9 +547,7 @@ export class BranchController extends Controller {
|
|||
|
||||
await permissionCheck(req.user, record);
|
||||
|
||||
if (record.status !== Status.CREATED) {
|
||||
throw new HttpError(HttpStatus.FORBIDDEN, "Branch is in used.", "branchInUsed");
|
||||
}
|
||||
if (record.status !== Status.CREATED) throw isUsedError("Branch");
|
||||
|
||||
return await prisma.$transaction(async (tx) => {
|
||||
const data = await tx.branch.delete({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue