Skip to content

Commit acaa371

Browse files
committed
Update: Add render exeption function
1 parent cb072e9 commit acaa371

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Classes/Service/FusionService.php

+21
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Neos\Fusion\Core\FusionSourceCodeCollection;
1212
use Neos\Fusion\Core\Parser;
1313
use Neos\Fusion\Core\RuntimeFactory as FusionRuntimeFactory;
14+
use Neos\Fusion\Exception;
1415
use Neos\Fusion\Exception\RuntimeException;
1516
use Neos\Neos\Domain\Repository\SiteRepository;
1617
use Neos\Neos\Domain\Service\FusionSourceCodeFactory;
@@ -82,6 +83,26 @@ public function render(array $contextProperties, string $html, ?string $props =
8283
}
8384
}
8485

86+
/**
87+
* Output an exception as a string in a red colored box
88+
*
89+
* @param Exception $exeption
90+
* @return string
91+
*/
92+
public function renderException(Exception $exeption): string
93+
{
94+
$content = htmlspecialchars(
95+
(string) $exeption->getMessage(),
96+
ENT_NOQUOTES | ENT_HTML401,
97+
ini_get('default_charset'),
98+
true
99+
);
100+
$open =
101+
'<span style="font-family: monospace; max-height: none; font-size: 1rem; width: 100%; margin: 30px auto; color: #fff; background: #d9534f; box-shadow: 0 1px 10px rgba(0,0,0,0.1); padding: 5% 12px; display: block; height: auto;">';
102+
$close = '</span>';
103+
return $open . $content . $close;
104+
}
105+
85106
private function parseFusionSourceCode(string $fusionSourceCode, ?TraversableNodeInterface $currentSiteNode): FusionConfiguration
86107
{
87108
return $this->fusionParser->parseFromSource(

0 commit comments

Comments
 (0)