Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/helpermodules/exceptions/requests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from requests import HTTPError
from requests.exceptions import ConnectionError
from requests.exceptions import ConnectionError, ReadTimeout

from helpermodules.exceptions.registry import ExceptionRegistry

Expand All @@ -8,6 +8,10 @@ def handle_connection_error(e: ConnectionError):
return "Die Verbindung zum Server {} ist fehlgeschlagen. Überprüfe Adresse und Netzwerk.".format(e.request.url)


def handle_read_timeout(e: ReadTimeout):
return "Innerhalb des Timeouts wurde keine Anwort erhalten. Überprüfe Adresse und Netzwerk."


def handle_http_error(e: HTTPError):
code = e.response.status_code
if 400 <= code < 500:
Expand All @@ -22,3 +26,4 @@ def handle_http_error(e: HTTPError):
def register_request_exception_handlers(registry: ExceptionRegistry) -> None:
registry.add(ConnectionError, handle_connection_error)
registry.add(HTTPError, handle_http_error)
registry.add(ReadTimeout, handle_read_timeout)
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, config: OpenWBPro) -> None:

def set_internal_context_handlers(self, parent_cp, parent_hostname):
self.fault_state = FaultState(ComponentInfo(
parent_cp,
self.config.id,
"Ladepunkt "+str(self.config.id),
"chargepoint",
parent_id=parent_cp,
Expand Down