From fa8e21166bf540b923fc53931ef0cfe25e17ddf8 Mon Sep 17 00:00:00 2001 From: puriphat Date: Fri, 14 Jun 2024 04:41:03 +0000 Subject: [PATCH] fix: product code --- src/controllers/product/product-controller.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controllers/product/product-controller.ts b/src/controllers/product/product-controller.ts index 59e550e..aabdbc5 100644 --- a/src/controllers/product/product-controller.ts +++ b/src/controllers/product/product-controller.ts @@ -97,7 +97,7 @@ export class ProductController extends Controller { }); if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "Product cannot be found.", "data_not_found"); + throw new HttpError(HttpStatus.NOT_FOUND, "Product cannot be found.", "productNotFound"); } return Object.assign(record, { @@ -156,7 +156,7 @@ export class ProductController extends Controller { @Path() productId: string, ) { if (!(await prisma.product.findUnique({ where: { id: productId } }))) { - throw new HttpError(HttpStatus.NOT_FOUND, "Product cannot be found.", "data_not_found"); + throw new HttpError(HttpStatus.NOT_FOUND, "Product cannot be found.", "productNotFound"); } const record = await prisma.product.update({ @@ -182,11 +182,11 @@ export class ProductController extends Controller { const record = await prisma.product.findFirst({ where: { id: productId } }); if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "Product cannot be found.", "data_not_found"); + throw new HttpError(HttpStatus.NOT_FOUND, "Product cannot be found.", "productNotFound"); } if (record.status !== Status.CREATED) { - throw new HttpError(HttpStatus.FORBIDDEN, "Product is in used.", "data_in_used"); + throw new HttpError(HttpStatus.FORBIDDEN, "Product is in used.", "productInUsed"); } return await prisma.product.delete({ where: { id: productId } });