Skip to content

Commit

Permalink
feat: make WaitingForEarlyReturn public and keep compatibility with O…
Browse files Browse the repository at this point in the history
…nFailureException to avoid errors on incorrect third-party integrations (#71)
  • Loading branch information
acostapazo authored Nov 27, 2023
1 parent 95b30b7 commit bbe035c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions meiga/on_failure_exception.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from meiga.failures import WaitingForEarlyReturn

OnFailureException = WaitingForEarlyReturn
2 changes: 2 additions & 0 deletions meiga/public_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .decorators.early_return import early_return
from .decorators.to_result import to_result
from .error import Error
from .failures import WaitingForEarlyReturn
from .handlers import OnFailureHandler, OnSuccessHandler
from .result import Result

Expand All @@ -29,4 +30,5 @@
"OnFailureHandler",
"to_result",
"early_return",
"WaitingForEarlyReturn",
]
14 changes: 12 additions & 2 deletions tests/unit/test_waiting_for_early_return.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from meiga import Error, Result
from meiga.failures import WaitingForEarlyReturn
from meiga import Error, Result, WaitingForEarlyReturn
from meiga.on_failure_exception import OnFailureException


def expected_error(value: str) -> str:
Expand All @@ -28,3 +28,13 @@ def should_str_as_expected_an_exception(self):
exception = WaitingForEarlyReturn(result)

assert expected_error(wrapped_exception.__repr__()) == str(exception)

def should_be_compatible_with_older_version_and_expect_st_as_expected_an_exception(
self,
):
wrapped_exception = ValueError("Something went wrong")
result = Result(failure=wrapped_exception)

exception = OnFailureException(result)

assert expected_error(wrapped_exception.__repr__()) == str(exception)

0 comments on commit bbe035c

Please sign in to comment.