refactor(api): Refactor error handling in add() function
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
f7e90567d7
commit
16cf984ddc
5
app.py
5
app.py
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user