Add OxiAPIError exception class for improved error handling

- Introduced a new `OxiAPIError` class to standardize error reporting in the OxiAPI.
- The class includes an optional status code for enhanced context in error messages.
This commit is contained in:
IluaAir
2026-03-26 00:39:43 +03:00
parent 8cebbf743a
commit 61892d8f51

12
oxi/exception.py Normal file
View File

@@ -0,0 +1,12 @@
from typing import Optional
class OxiAPIError(Exception):
def __init__(self, message: str, status_code: Optional[int] = None):
super().__init__(message)
self.status_code = status_code
def __str__(self):
if self.status_code is not None:
return f"OxiAPIError: {self.args[0]} (HTTP {self.status_code})"
return f"OxiAPIError: {self.args[0]}"