From f0373c213a7a8860780551d0250a6270c3f26c52 Mon Sep 17 00:00:00 2001 From: nfesta2023 <142601504+nfesta2023@users.noreply.github.com> Date: Sun, 18 Feb 2024 11:26:16 +0700 Subject: [PATCH] FES-64-handle-unavailable-delivery-time-for-cart-2 (#58) * adjust the status code return Co-authored-by: NHT --- src/feature/cart/cart.controller.ts | 7 ++++++- src/feature/cart/cart.service.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/feature/cart/cart.controller.ts b/src/feature/cart/cart.controller.ts index 5b5bc7b..9bce96d 100644 --- a/src/feature/cart/cart.controller.ts +++ b/src/feature/cart/cart.controller.ts @@ -331,7 +331,12 @@ export class CartController { } } catch (error) { if (error instanceof HttpException) { - res.statusCode = error.getStatus(); + if (error.getStatus() == 404) { + res.statusCode = 400; + } else { + res.statusCode = error.getStatus(); + } + res.message = error.getResponse(); res.data = null; } else { diff --git a/src/feature/cart/cart.service.ts b/src/feature/cart/cart.service.ts index 369d656..8562ab9 100644 --- a/src/feature/cart/cart.service.ts +++ b/src/feature/cart/cart.service.ts @@ -655,7 +655,7 @@ export class CartService { //Check if menu_item_ids do exist if (menuItems.length != menu_item_ids.length) { - throw new HttpException('Some of menu items do not exist', 404); + throw new HttpException('Some of menu items do not exist', 400); } //Check if menu_item_ids belong to the same restaurant