fix: error on not exist

This commit is contained in:
Methapon2001 2024-04-05 14:43:21 +07:00
parent 58611f8589
commit 011d53d655

View file

@ -194,6 +194,10 @@ export class CustomerBranchController extends Controller {
const { provinceId, districtId, subDistrictId, customerId, ...rest } = body;
if (!(await prisma.customerBranch.findUnique({ where: { id: branchId } }))) {
throw new HttpError(HttpStatus.NOT_FOUND, "Branch cannot be found.", "data_not_found");
}
const record = await prisma.customerBranch.update({
where: { id: branchId },
include: {