diff --git a/liqpy/exceptions.py b/liqpy/exceptions.py index ff675a0..9b1cce3 100644 --- a/liqpy/exceptions.py +++ b/liqpy/exceptions.py @@ -1,6 +1,9 @@ -from typing import Literal +from typing import Literal, TYPE_CHECKING, Optional from copy import deepcopy +if TYPE_CHECKING: + from requests import Response + def is_exception( action: str, @@ -15,9 +18,11 @@ def is_exception( class LiqPayException(Exception): code: str - data: dict + details: dict + response: Optional["Response"] = None - def __init__(self, code: str, description: str, /, **kwargs): + def __init__(self, code: str, description: str, /, response: Optional["Response"] = None, **kwargs): super().__init__(description) self.code = code - self.data = deepcopy(kwargs) + self.response = response + self.details = deepcopy(kwargs) diff --git a/readme.ipynb b/readme.ipynb index 98027ea..278765a 100644 --- a/readme.ipynb +++ b/readme.ipynb @@ -68,7 +68,8 @@ "try:\n", " liqpay.request(**params)\n", "except LiqPayException as e:\n", - " pprint(e.data)\n", + " print(e.response)\n", + " pprint(e.details)\n", " raise e" ] },