Skip to content

Commit

Permalink
NEW: add ErrorResponse.as_exception()
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenein committed Nov 28, 2023
1 parent b2a6e97 commit c86fec3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions combadge/core/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,16 @@ def raise_for_result(self, exception: BaseException | None = None) -> NoReturn:
"""
if not exception:
raise self.Error(self)
raise exception from self.Error(self)
raise exception from self.as_exception()

def unwrap(self) -> NoReturn:
"""Raise the derived exception."""
raise self.Error(self)
raise self.as_exception()

def as_exception(self) -> _BaseDerivedError:
"""
Return the derived exception without raising it.
Convenience wrapper around `self.Error(self)` as the exception class requires the response as an argument.
"""
return self.Error(self)

0 comments on commit c86fec3

Please sign in to comment.