Use HTTP_NOT_FOUND constant (#33835)
This commit is contained in:
parent
ac9429988b
commit
9a40d5b7ed
29 changed files with 98 additions and 78 deletions
|
@ -5,6 +5,7 @@ import voluptuous as vol
|
|||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.components.http import HomeAssistantView
|
||||
from homeassistant.components.http.data_validator import RequestDataValidator
|
||||
from homeassistant.const import HTTP_NOT_FOUND
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
# mypy: allow-untyped-calls, allow-untyped-defs
|
||||
|
@ -62,7 +63,7 @@ class FlowManagerIndexView(_BaseFlowManagerView):
|
|||
handler, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
except data_entry_flow.UnknownHandler:
|
||||
return self.json_message("Invalid handler specified", 404)
|
||||
return self.json_message("Invalid handler specified", HTTP_NOT_FOUND)
|
||||
except data_entry_flow.UnknownStep:
|
||||
return self.json_message("Handler does not support user", 400)
|
||||
|
||||
|
@ -79,7 +80,7 @@ class FlowManagerResourceView(_BaseFlowManagerView):
|
|||
try:
|
||||
result = await self._flow_mgr.async_configure(flow_id)
|
||||
except data_entry_flow.UnknownFlow:
|
||||
return self.json_message("Invalid flow specified", 404)
|
||||
return self.json_message("Invalid flow specified", HTTP_NOT_FOUND)
|
||||
|
||||
result = self._prepare_result_json(result)
|
||||
|
||||
|
@ -91,7 +92,7 @@ class FlowManagerResourceView(_BaseFlowManagerView):
|
|||
try:
|
||||
result = await self._flow_mgr.async_configure(flow_id, data)
|
||||
except data_entry_flow.UnknownFlow:
|
||||
return self.json_message("Invalid flow specified", 404)
|
||||
return self.json_message("Invalid flow specified", HTTP_NOT_FOUND)
|
||||
except vol.Invalid:
|
||||
return self.json_message("User input malformed", 400)
|
||||
|
||||
|
@ -104,6 +105,6 @@ class FlowManagerResourceView(_BaseFlowManagerView):
|
|||
try:
|
||||
self._flow_mgr.async_abort(flow_id)
|
||||
except data_entry_flow.UnknownFlow:
|
||||
return self.json_message("Invalid flow specified", 404)
|
||||
return self.json_message("Invalid flow specified", HTTP_NOT_FOUND)
|
||||
|
||||
return self.json_message("Flow aborted")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue