重新抛出异常

异常处理

def method_with_exception():
    try:
        raise Exception("test exception")
    except Exception as ex:
        # 实现任意部分处理,
        # 并把错误传给调用方代码
        raise ex


try:
    method_with_exception()
except Exception as e:
    print(e.args[0])