summaryrefslogtreecommitdiff
path: root/tests/basics/exception_chain.py
blob: cf19f049500da5229fa11246f483778bad274a57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Exception chaining is not supported, but check that basic
# exception works as expected.

import sys

# The unix minimal build doesn't enable MICROPY_WARNINGS (required for this test).
if getattr(sys.implementation, "_build", None) == "minimal":
    print("SKIP")
    raise SystemExit

try:
    raise Exception from None
except Exception:
    print("Caught Exception")

try:
    try:
        raise ValueError("Value")
    except Exception as exc:
        raise RuntimeError("Runtime") from exc
except Exception as ex2:
    print("Caught Exception:", ex2)