summaryrefslogtreecommitdiff
path: root/pyvyos/exceptions.py
blob: 5a797333b8a700a68fa5ab29a5c3a54cd1feddbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""PyVyOS exception hierarchy for typed error handling."""


class SDKError(Exception):
    """Base exception for all PyVyOS SDK errors."""
    pass


class HttpError(SDKError):
    """HTTP-level errors (network, timeout, status codes)."""
    
    def __init__(self, status: int, message: str):
        self.status = status
        self.message = message
        super().__init__(f"HTTP Error {status}: {message}")


class ApiError(SDKError):
    """API-level errors (when VyOS API returns success=False)."""
    
    def __init__(self, message: str, details: dict = None):
        self.message = message
        self.details = details
        super().__init__(message)


class ValidationError(SDKError):
    """Client-side validation errors (invalid parameters)."""
    
    def __init__(self, message: str):
        self.message = message
        super().__init__(message)