def fn1(exceptionCatcher): def fn2(): _console.log("tryRunning执行了1") _exceptions.throwException(lambda eb: eb.setMessage("xxx")) _console.log("不会执行到这里") return "没有异常" exceptionCatcher.tryRunning(fn2) def fn3(it): _console.log("catchException执行了") return "出现异常" + it.getMessage() exceptionCatcher.catchException(fn3) def fn4(): _console.log("finally run 1...") exceptionCatcher.finallyRun(fn4) result = _exceptions.tryCatch(fn1) _console.log("result", result) def fn5(exceptionCatcher): def fn6(): _console.log("tryRunning执行了2") return "没有异常" exceptionCatcher.tryRunning(fn6) def fn7(it): _console.log("不会执行到这里") return "出现异常" + it.getMessage() exceptionCatcher.catchException(fn7) def fn8(): _console.log("finally run 2...") exceptionCatcher.finallyRun(fn8) result = _exceptions.tryCatch(fn5) _console.log("result", result)