From 2e646054ff5f5e9f4dacc3f6055bc52e3274d434 Mon Sep 17 00:00:00 2001 From: Ching Date: Mon, 4 Mar 2024 21:04:59 +0800 Subject: [PATCH] fix(api): Add error handling for item not found --- app.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app.py b/app.py index cc1d5ec..212a871 100644 --- a/app.py +++ b/app.py @@ -203,6 +203,9 @@ def add(): spider = BarcodeSpider(x_rapidapi_key=X_RapidAPI_Key) good = spider.get_good(barcode) + if not good: + response_data = {"message": "Item not found"} + return jsonify(response_data), 400 try: if add_product(good, location): response_data = {"message": "New item added successfully"}