36 lines
920 B
Python
36 lines
920 B
Python
"""Exception types shared by every proxdomain module."""
|
|||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
|
||
|
|
class ProxdomainError(Exception):
|
||
|
|
"""Base class for all expected, user-facing failures."""
|
||
|
|
|
||
|
|
|
||
|
|
class ConfigError(ProxdomainError):
|
||
|
|
"""The configuration file is missing, malformed or incomplete."""
|
||
|
|
|
||
|
|
|
||
|
|
class ApiError(ProxdomainError):
|
||
|
|
"""A remote API (Proxmox VE or Cloudflare) returned an error."""
|
||
|
|
|
||
|
|
def __init__(
|
||
|
|
self,
|
||
|
|
message: str,
|
||
|
|
*,
|
||
|
|
status: int | None = None,
|
||
|
|
payload: object | None = None,
|
||
|
|
url: str | None = None,
|
||
|
|
) -> None:
|
||
|
|
super().__init__(message)
|
||
|
|
self.status = status
|
||
|
|
self.payload = payload
|
||
|
|
self.url = url
|
||
|
|
|
||
|
|
@property
|
||
|
|
def is_auth_error(self) -> bool:
|
||
|
|
return self.status in (401, 403)
|
||
|
|
|
||
|
|
|
||
|
|
class WebServerError(ProxdomainError):
|
||
|
|
"""Writing, validating or reloading the web server configuration failed."""
|