Improve invalid error messages in the config flows (#108075)

This commit is contained in:
Robert Resch 2024-01-30 12:24:19 +01:00 committed by GitHub
parent 8ad0226241
commit 6fdad44941
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 162 additions and 23 deletions

View file

@ -110,10 +110,8 @@ class FlowManagerResourceView(_BaseFlowManagerView):
result = await self._flow_mgr.async_configure(flow_id, data)
except data_entry_flow.UnknownFlow:
return self.json_message("Invalid flow specified", HTTPStatus.NOT_FOUND)
except vol.Invalid as ex:
return self.json_message(
f"User input malformed: {ex}", HTTPStatus.BAD_REQUEST
)
except data_entry_flow.InvalidData as ex:
return self.json({"errors": ex.schema_errors}, HTTPStatus.BAD_REQUEST)
result = self._prepare_result_json(result)