diff options
| author | roberto berto <rberto@deepcausa.com> | 2025-11-02 22:54:44 +0000 |
|---|---|---|
| committer | roberto berto <rberto@deepcausa.com> | 2025-11-02 22:54:44 +0000 |
| commit | 6b4e9015744ab8c9f17a6b8e23387cd676b1d827 (patch) | |
| tree | 4c0a634730df2123ff506252cbec050de006dac8 /pyvyos/exceptions.py | |
| parent | 1ada32975f0bb559ec7526e0dd545700dde1cb94 (diff) | |
| download | pyvyos-6b4e9015744ab8c9f17a6b8e23387cd676b1d827.tar.gz pyvyos-6b4e9015744ab8c9f17a6b8e23387cd676b1d827.zip | |
feat: v0.4.0 - Architecture refactor, bug fixes, and quality improvementsfeat/architecture-and-quality-improvements
- Fixed #25: config_file_save/load now include path: [] in payload
- Added exception hierarchy (SDKError, HttpError, ApiError, ValidationError)
- Added utility functions (json, ids, paths)
- Added structured logging with request ID tracking
- Added optional Pydantic validation models
- Refactored to pyvyos.core.* structure with backward compatibility shims
- Moved JSON specs to docs/development/vyos_api/
- Added comprehensive test suite (19 shim tests, 16 utils tests, 6 exception tests)
- Updated pyproject.toml for uv sync editable installation
- Added development documentation (architecture, roadmap, quality guidelines)
Maintains 100% backward compatibility with 0.3.0
Diffstat (limited to 'pyvyos/exceptions.py')
| -rw-r--r-- | pyvyos/exceptions.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/pyvyos/exceptions.py b/pyvyos/exceptions.py new file mode 100644 index 0000000..5a79733 --- /dev/null +++ b/pyvyos/exceptions.py @@ -0,0 +1,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) + |
