kernel->beginExecution($descriptor); $outcome = ExecutionOutcome::incomplete(); try { $result = $execution($scope); $outcome = ExecutionOutcome::success($result); return $result; } catch (\Throwable $error) { if ($failure === null) { $outcome = ExecutionOutcome::failure($error); throw $error; } try { $result = $failure($error, $scope); $outcome = ExecutionOutcome::failure($error, $result); return $result; } catch (\Throwable $failureError) { $outcome = ExecutionOutcome::failure($failureError); throw $failureError; } } finally { $this->kernel->terminateExecution($scope, $outcome); } } }