Skip to content

Commit

Permalink
refactor: rename correlation id variable
Browse files Browse the repository at this point in the history
  • Loading branch information
jooola committed Jul 3, 2024
1 parent cf08842 commit 3443fa7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions hcloud/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def request( # type: ignore[no-untyped-def]
**kwargs,
)

trace_id = response.headers.get("X-Correlation-Id")
correlation_id = response.headers.get("X-Correlation-Id")
payload = {}
try:
if len(response.content) > 0:
Expand All @@ -225,7 +225,7 @@ def request( # type: ignore[no-untyped-def]
code=response.status_code,
message=response.reason,
details={"content": response.content},
trace_id=trace_id,
correlation_id=correlation_id,
) from exc

if not response.ok:
Expand All @@ -234,7 +234,7 @@ def request( # type: ignore[no-untyped-def]
code=response.status_code,
message=response.reason,
details={"content": response.content},
trace_id=trace_id,
correlation_id=correlation_id,
)

error: dict = payload["error"]
Expand All @@ -248,7 +248,7 @@ def request( # type: ignore[no-untyped-def]
code=error["code"],
message=error["message"],
details=error["details"],
trace_id=trace_id,
correlation_id=correlation_id,
)

return payload
8 changes: 4 additions & 4 deletions hcloud/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ def __init__(
message: str,
details: Any,
*,
trace_id: str | None = None,
correlation_id: str | None = None,
):
extras = [str(code)]
if trace_id is not None:
extras.append(trace_id)
if correlation_id is not None:
extras.append(correlation_id)

error = f"{message} ({', '.join(extras)})"

super().__init__(error)
self.code = code
self.message = message
self.details = details
self.trace_id = trace_id
self.correlation_id = correlation_id

0 comments on commit 3443fa7

Please sign in to comment.