tryCatch(function ($exceptionCatcher) use ($console, $exceptions) { $exceptionCatcher->tryRunning(function () use ($console, $exceptions) { $console->log("tryRunning执行了1"); $exceptions->throwException(function ($eb) { $eb->setMessage("xxx"); }); $console->log("不会执行到这里"); return "没有异常"; }); $exceptionCatcher->catchException(function ($it) use ($console) { $console->log("catchException执行了"); return "出现异常" . $it->getMessage(); }); $exceptionCatcher->finallyRun(function () use ($console) { $console->log("finally run 1..."); }); }); $console->log("result", $result); $result = $exceptions->tryCatch(function ($exceptionCatcher) use ($console) { $exceptionCatcher->tryRunning(function () use ($console) { $console->log("tryRunning执行了2"); return "没有异常"; }); $exceptionCatcher->catchException(function ($it) use ($console) { $console->log("不会执行到这里"); return "出现异常" . $it->getMessage(); }); $exceptionCatcher->finallyRun(function () use ($console) { $console->log("finally run 2..."); }); }); $console->log("result", $result);