From 61892d8f514e14771e0157fe5dcd96fd194e6f98 Mon Sep 17 00:00:00 2001 From: IluaAir Date: Thu, 26 Mar 2026 00:39:43 +0300 Subject: [PATCH] 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. --- oxi/exception.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 oxi/exception.py diff --git a/oxi/exception.py b/oxi/exception.py new file mode 100644 index 0000000..77f746b --- /dev/null +++ b/oxi/exception.py @@ -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]}"