mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Use why instead of e
This commit is contained in:
parent
2cda66dd0b
commit
53bf5a0730
@ -100,18 +100,19 @@ class ApiCraftyConfigIndexHandler(BaseApiHandler):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
data = orjson.loads(self.request.body)
|
data = orjson.loads(self.request.body)
|
||||||
except orjson.JSONDecodeError as e:
|
except orjson.JSONDecodeError as why:
|
||||||
return self.finish_json(
|
return self.finish_json(
|
||||||
400, {"status": "error", "error": "INVALID_JSON", "error_data": str(e)}
|
400,
|
||||||
|
{"status": "error", "error": "INVALID_JSON", "error_data": str(why)},
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
validate(data, config_json_schema)
|
validate(data, config_json_schema)
|
||||||
except ValidationError as e:
|
except ValidationError as why:
|
||||||
offending_key = e.path[0] if e.path else None
|
offending_key = why.path[0] if why.path else None
|
||||||
err = f"""{self.translator.translate(
|
err = f"""{self.translator.translate(
|
||||||
"validators",
|
"validators",
|
||||||
e.schema.get("error"),
|
why.schema.get("error"),
|
||||||
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
|
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
|
||||||
)} {offending_key}"""
|
)} {offending_key}"""
|
||||||
return self.finish_json(
|
return self.finish_json(
|
||||||
|
Loading…
Reference in New Issue
Block a user