first commit
This commit is contained in:
commit
dd50a0d05e
31 files changed
+5299
No files matched your search
Executable
+36
@@ -0,0 +1,36 @@
|
||||
"""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."""
|
||||
Reference in new issue
Block a user