Add exception handling for chargepoint reset
This commit is contained in:
parent
6f998a3c58
commit
161c6aa027
|
@ -130,9 +130,12 @@ async def reset_chargepoint(
|
|||
api_key: str = Security(get_api_key)
|
||||
):
|
||||
if chargepoint_manager.is_connected(chargepoint_id) == False:
|
||||
raise HTTPException(status_code=423, detail="Chargepoint not connected")
|
||||
raise HTTPException(status_code=503, detail="Chargepoint not connected.")
|
||||
try:
|
||||
response = await chargepoint_manager.call(
|
||||
chargepoint_id,
|
||||
payload=ResetPayload(type=reset_request.type, evse_id=reset_request.evse_id)
|
||||
)
|
||||
return ChargePointResetResponse(status=response.status)
|
||||
except TimeoutError:
|
||||
raise HTTPException(status_code=503, detail="Chargepoint didn't respond in time.")
|
||||
|
|
Loading…
Reference in a new issue