Skip to content
On this page

INFO

@Author: MicLon
@Date: 2023/02/27
@Description: 捕获函数执行中的异常

使用

@useCatchError装饰器,用于捕获函数执行中的异常

python
from usepy import useCatchError


@useCatchError()
def exception_demo():
    raise Exception('test')


@useCatchError(return_val='test')
def exception_demo2():
    raise Exception('test')


print(exception_demo())  # None
print(exception_demo2())  # 'test'
print("run to here")

Released under the MIT License.