Sobes.tech
Junior — Senior

Context manager suppressing specified exceptions

livecode

Task condition

It is necessary to implement a context manager suppress that ignores specified exception types.

Example 1:

with suppress(ValueError):
    raise ValueError
print("OK")

Expected output: "OK"

Example 2:

with suppress(ValueError):
    raise TypeError

Expected result: TypeError will be propagated outward.