Skip to content

Commit

Permalink
add response to exception
Browse files Browse the repository at this point in the history
  • Loading branch information
rostyq committed Oct 25, 2023
1 parent 694b4aa commit 82ebc79
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
13 changes: 9 additions & 4 deletions liqpy/exceptions.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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)
3 changes: 2 additions & 1 deletion readme.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
Expand Down

0 comments on commit 82ebc79

Please sign in to comment.