Skip to content

Commit

Permalink
TASK: Runtime renderResponse unwrap RuntimeException itself
Browse files Browse the repository at this point in the history
Previously the pattern was that the utmost caller of the runtime would unwrap the exception.
To simplify this, as the runtime now has a single entry point, we add this behaviour into the runtime.
  • Loading branch information
mhsdesign committed Feb 16, 2024
1 parent 1dd307c commit b737c01
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
3 changes: 3 additions & 0 deletions Neos.Fusion/Classes/Core/Runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ public function renderResponse(string $fusionPath, array $contextArray): Respons
return $this->withSimulatedLegacyControllerContext(function () use ($fusionPath) {
try {
$output = $this->render($fusionPath);
} catch (RuntimeException $exception) {
// unwrap the FusionRuntimeException
throw $exception->getPrevious();

Check failure on line 282 in Neos.Fusion/Classes/Core/Runtime.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 Test linting-unit-functionaltests-mysql (deps: highest)

Invalid type Throwable|null to throw.

Check failure on line 282 in Neos.Fusion/Classes/Core/Runtime.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 Test linting-unit-functionaltests-mysql (deps: highest)

Invalid type Throwable|null to throw.
} finally {
$this->popContext();
}
Expand Down
6 changes: 1 addition & 5 deletions Neos.Fusion/Classes/View/FusionView.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,7 @@ public function render()
$this->initializeFusionRuntime();

if ($this->getOption('renderHttpResponse') === true) {
try {
return $this->fusionRuntime->renderResponse($this->getFusionPathForCurrentRequest(), $this->variables);
} catch (RuntimeException $exception) {
throw $exception->getPrevious();
}
return $this->fusionRuntime->renderResponse($this->getFusionPathForCurrentRequest(), $this->variables);
} else {
try {
$this->fusionRuntime->pushContextArray($this->variables);
Expand Down
16 changes: 5 additions & 11 deletions Neos.Neos/Classes/View/FusionView.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

namespace Neos\Neos\View;

use GuzzleHttp\Psr7\Message;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindClosestNodeFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
Expand All @@ -24,7 +23,6 @@
use Neos\Fusion\Core\FusionGlobals;
use Neos\Fusion\Core\Runtime;
use Neos\Fusion\Core\RuntimeFactory;
use Neos\Fusion\Exception\RuntimeException;
use Neos\Neos\Domain\Model\RenderingMode;
use Neos\Neos\Domain\Repository\SiteRepository;
use Neos\Neos\Domain\Service\FusionService;
Expand Down Expand Up @@ -74,15 +72,11 @@ public function render(): ResponseInterface

$fusionRuntime = $this->getFusionRuntime($currentSiteNode);

try {
return $fusionRuntime->renderResponse($this->fusionPath, [
'node' => $currentNode,
'documentNode' => $this->getClosestDocumentNode($currentNode) ?: $currentNode,
'site' => $currentSiteNode
]);
} catch (RuntimeException $exception) {
throw $exception->getPrevious() ?: $exception;
}
return $fusionRuntime->renderResponse($this->fusionPath, [
'node' => $currentNode,
'documentNode' => $this->getClosestDocumentNode($currentNode) ?: $currentNode,
'site' => $currentSiteNode
]);
}

/**
Expand Down

0 comments on commit b737c01

Please sign in to comment.