let result = $exceptions.tryCatch((exceptionCatcher) => { exceptionCatcher.tryRunning(() => { $console.log("tryRunning执行了1") $exceptions.throwException((eb) => { let NullPointerException = $java.loadClass("java.lang.NullPointerException") eb.setThrowable(new NullPointerException("xxx is null")) }) $console.log("不会执行到这里") return "没有异常" }) exceptionCatcher.catchException((it) => { $console.log("catchException执行了") return "出现异常" + it.getMessage() }) exceptionCatcher.finallyRun(() => { $console.log("finally run 1...") }) }) $console.log("result", result) result = $exceptions.tryCatch((exceptionCatcher) => { exceptionCatcher.tryRunning(() => { $console.log("tryRunning执行了2") return "没有异常" }) exceptionCatcher.catchException((it) => { $console.log("不会执行到这里") return "出现异常" + it.getMessage() }) exceptionCatcher.finallyRun(() => { $console.log("finally run 2...") }) }) $console.log("result", result)