From e7e090ecbd69e4e0cf517c297787e971ff55fb1a Mon Sep 17 00:00:00 2001 From: puriphat Date: Fri, 14 Jun 2024 05:42:43 +0000 Subject: [PATCH] fix: type code --- src/controllers/product/type-controller.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/controllers/product/type-controller.ts b/src/controllers/product/type-controller.ts index 93db012..a764c76 100644 --- a/src/controllers/product/type-controller.ts +++ b/src/controllers/product/type-controller.ts @@ -73,7 +73,7 @@ export class ProductType extends Controller { }); if (!record) - throw new HttpError(HttpStatus.NOT_FOUND, "Product type cannot be found.", "data_not_found"); + throw new HttpError(HttpStatus.NOT_FOUND, "Product type cannot be found.", "productTypeNotFound"); return record; } @@ -88,7 +88,7 @@ export class ProductType extends Controller { throw new HttpError( HttpStatus.BAD_REQUEST, "Product group associated cannot be found.", - "missing_or_invalid_parameter", + "productGroupAssociatedBadReq", ); } @@ -135,12 +135,12 @@ export class ProductType extends Controller { throw new HttpError( HttpStatus.BAD_REQUEST, "Product group cannot be found.", - "missing_or_invalid_parameter", + "productGroupBadReq", ); } if (!(await prisma.productType.findUnique({ where: { id: typeId } }))) { - throw new HttpError(HttpStatus.NOT_FOUND, "Product type cannot be found.", "data_not_found"); + throw new HttpError(HttpStatus.NOT_FOUND, "Product type cannot be found.", "productTypeNotFound"); } const record = await prisma.productType.update({ @@ -156,11 +156,11 @@ export class ProductType extends Controller { const record = await prisma.productType.findFirst({ where: { id: typeId } }); if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "Product type cannot be found.", "data_not_found"); + throw new HttpError(HttpStatus.NOT_FOUND, "Product type cannot be found.", "productTypeNotFound"); } if (record.status !== Status.CREATED) { - throw new HttpError(HttpStatus.FORBIDDEN, "Product type is in used.", "data_in_used"); + throw new HttpError(HttpStatus.FORBIDDEN, "Product type is in used.", "productTypeInUsed"); } return await prisma.productType.delete({ where: { id: typeId } });