Skip to content

Commit 6f16751

Browse files
committed
Improved error handling if connection to server could not be established
Signed-off-by: Daniel Klein <daniel.klein@em.ag>
1 parent 5c2fe3b commit 6f16751

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

aas_http_client/classes/client/aas_client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ def get_root(self) -> dict | None:
145145

146146
self.set_token()
147147

148+
error_messages: dict[int, str] = {}
149+
148150
for url in urls:
149151
_logger.debug(f"Testing connectivity with URL: {url}")
150152
try:
@@ -155,10 +157,14 @@ def get_root(self) -> dict | None:
155157
content = response.content.decode("utf-8")
156158
return json.loads(content)
157159

160+
if response.status_code not in (STATUS_CODE_200, STATUS_CODE_201, STATUS_CODE_204):
161+
content = response.content.decode("utf-8")
162+
error_messages.update({response.status_code: content})
163+
158164
except requests.exceptions.RequestException as e:
159165
_logger.error(f"Error call REST API: {e}")
160166

161-
return None
167+
raise ConnectionError(f"Failed to connect to AAS server API. Error messages: {error_messages}")
162168

163169
def set_token(self) -> str | None:
164170
"""Set authentication token in session headers based on configured authentication method.

docs/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# 📝 Changelog
22

3-
## [1.1.6] - 2026-06-11
3+
## [1.1.7] - 2026-06-25
4+
5+
* 🚀Improvement: Improved error handling if connection to server could not be established
6+
7+
## [1.1.6] - 2026-06-25
48

59
* 🚀Improvement: Improved configuration model validation in creation of the client and the wrapper and allow using alias and internal name
610

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "aas-http-client"
7-
version = "1.1.6"
7+
version = "1.1.7"
88
description = "Flexible Python HTTP client for communication with various types of AAS servers."
99
readme = "README.md"
1010
license = { file = "LICENSE" }

0 commit comments

Comments
 (0)