Commit aac7ad14 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Titouan Soulard

erp5_api_style: Put and get return error directly if schema doesn't match

As get and put actions are deterministic there is no need to loop
over various schemas when checking data. If there is an error it is
returned directly.
parent 5d281f31
...@@ -119,6 +119,11 @@ for erp5_action_key in erp5_action_dict.keys(): ...@@ -119,6 +119,11 @@ for erp5_action_key in erp5_action_dict.keys():
response.setStatus(201) response.setStatus(201)
return result return result
except ValueError as e: except ValueError as e:
if mode in ("put", "get"):
return logError(
"data did not match schema: %s" % e,
error_name="INPUT-DATA-DOES-NOT-MATCH-EXPECTED-DATA"
)
try: try:
error_dict.update(json.loads(str(e))) error_dict.update(json.loads(str(e)))
except ValueError: except ValueError:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment