34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
"""Иерархия ошибок хранилища awg-dash."""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
class StorageError(RuntimeError):
|
|
"""Базовая ошибка слоя хранения состояния."""
|
|
|
|
|
|
class SchemaError(StorageError):
|
|
"""Схема БД не соответствует ожидаемой версии (или требует отката)."""
|
|
|
|
|
|
class ValidationError(StorageError):
|
|
"""Данные не прошли валидацию до применения (стадия validate)."""
|
|
|
|
def __init__(self, field: str, message: str) -> None:
|
|
super().__init__(f"{field}: {message}")
|
|
self.field = field
|
|
self.message = message
|
|
|
|
|
|
class ApplyError(StorageError):
|
|
"""Ошибка применения конфигурации.
|
|
|
|
``restored`` — предыдущее состояние подтверждённо восстановлено,
|
|
``audit_id`` — id записи в audit_log, статус ``failed``.
|
|
"""
|
|
|
|
def __init__(self, message: str, *, restored: bool, audit_id: int | None) -> None:
|
|
super().__init__(message)
|
|
self.restored = restored
|
|
self.audit_id = audit_id
|