Skip to content

Commit

Permalink
Merge pull request #8845 from OpenMined/syft_error_improvements
Browse files Browse the repository at this point in the history
Proper exceptions for SyftResponseMessage
  • Loading branch information
teo-milea committed Jun 27, 2024
2 parents ee68336 + 987d144 commit 249735c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/syft/src/syft/service/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Any

# third party
from IPython.display import display
from result import Err

# relative
Expand All @@ -17,6 +18,27 @@ class SyftResponseMessage(SyftBaseModel):
_bool: bool = True
require_api_update: bool = False

def __getattr__(self, name: str) -> Any:
if name in [
"_bool",
# "_repr_html_",
# "message",
# 'require_api_update',
# '__bool__',
# '__eq__',
# '__repr__',
# '__str__',
# '_repr_html_class_',
# '_repr_html_',
"_ipython_canary_method_should_not_exist_",
"_ipython_display_",
] or name.startswith("_repr"):
return super().__getattr__(name)
display(self)
raise Exception(
f"You have tried accessing `{name}` on a {type(self).__name__} with message: {self.message}"
)

def __bool__(self) -> bool:
return self._bool

Expand Down

0 comments on commit 249735c

Please sign in to comment.