refactor(api): Refactor error handling in add() function
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Ching 2024-03-03 20:32:28 +08:00
parent f7e90567d7
commit 16cf984ddc

5
app.py
View File

@ -201,7 +201,10 @@ def add():
response_data = {"message": "Fail to add new item"}
return jsonify(response_data), 400
except Exception as e:
error_message = str(e)
if hasattr(e, "message"):
error_message = e.message
else:
error_message = str(e)
response_data = {"message": error_message}
return jsonify(response_data), 400