summaryrefslogtreecommitdiff
path: root/doc/data/messages/o/overlapping-except/good.py
blob: 0cace420e65df699df50acd42dd82dd65390ecf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def divide_x_by_y(x: float, y: float):
    try:
        print(x / y)
    except FloatingPointError as e:
        print(f"There was a FloatingPointError: {e}")
    except ArithmeticError as e:
        # FloatingPointError  were already caught at this point
        print(f"There was an OverflowError or a ZeroDivisionError: {e}")


# Or:


def divide_x_by_y(x: float, y: float):
    try:
        print(x / y)
    except ArithmeticError as e:
        print(
            f"There was an OverflowError, a ZeroDivisionError or a FloatingPointError: {e}"
        )