sematic icon indicating copy to clipboard operation
sematic copied to clipboard

Provide syntactic sugar for Exception layering matching

Open tscurtu opened this issue 2 years ago • 0 comments

The Exception layering scheme proposed in #264 will require rigorous and elaborate unit testing capabilities.

Currently we do have glimpse of the complexity needed to validate Exception handling. As an example:

    with pytest.raises(ResolutionError, match="FAIL!") as exc_info:
        future.resolve()

    assert isinstance(exc_info.value.__context__, CalculatorError)
    assert isinstance(exc_info.value.__context__.__context__, SomeException)

This patterns repeats several times through the codebase. There should be syntactic sugar that shortens this usage pattern, turning the above into:

    with sematic.raises(ResolutionError, CalculatorError, SomeException, match="FAIL!"):
        future.resolve()

tscurtu avatar Oct 28 '22 02:10 tscurtu