1
0
Fork 0
mirror of https://github.com/ansible-collections/hetzner.hcloud.git synced 2026-02-03 23:51:48 +00:00
hetzner.hcloud/plugins/module_utils/_vendor/hcloud/_exceptions.py
Jonas L. cfa0d181f7
refactor: mark module_utils modules as private (#782)
##### SUMMARY

All `module_utils` are now marked as **private**. None of the modules
were intended for public use.

Similar to
https://togithub.com/ansible-collections/community.general/issues/11312
2026-01-06 08:43:46 +01:00

35 lines
866 B
Python

from __future__ import annotations
from typing import Any
class HCloudException(Exception):
"""There was an error while using the hcloud library.
All exceptions in the hcloud library inherit from this exception. It may be used as
catch-all exception.
"""
class APIException(HCloudException):
"""There was an error while performing an API Request."""
def __init__(
self,
code: int | str,
message: str,
details: Any,
*,
correlation_id: str | None = None,
):
extras = [str(code)]
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.correlation_id = correlation_id