Skip to content

Commit

Permalink
Extend SolanaExceptionBase with Original Exception Field
Browse files Browse the repository at this point in the history
  • Loading branch information
pohape committed Dec 17, 2023
1 parent 892d444 commit e1f1194
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/solana/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ class SolanaExceptionBase(Exception):

def __init__(self, exc: Exception, func: Callable[[Any], Any], *args: Any, **kwargs: Any) -> None:
"""Init."""
def __init__(self, exc: Exception, func: Callable[[Any], Any], *args: Any, **kwargs: Any) -> None:
super().__init__()
self.error_msg = self._build_error_message(exc, func, *args, **kwargs)
self.original_exception = exc

@staticmethod
def _build_error_message(
Expand All @@ -17,7 +19,7 @@ def _build_error_message(
*args: Any, # noqa: ARG004
**kwargs: Any, # noqa: ARG004
) -> str:
return f"{type(exc)} raised in {func} invokation"
return f"{type(exc)} raised in {func} invokation\nOriginal exception: {exc}"


class SolanaRpcException(SolanaExceptionBase):
Expand Down

0 comments on commit e1f1194

Please sign in to comment.