Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend SolanaExceptionBase with Original Exception Field #386

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to set this since _build_error_message is a static method


@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
Loading