Skip to content

Commit 13b56e6

Browse files
committed
improve twig error logging
Signed-off-by: derMart <derMart@users.noreply.github.com>
1 parent cf9edc1 commit 13b56e6

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

lib/Service/PicoService.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
use OCP\Files\NotFoundException;
4444
use OCP\Files\NotPermittedException;
4545
use OCP\ILogger;
46+
use Twig\Error\Error;
4647

4748
class PicoService
4849
{
@@ -147,6 +148,16 @@ public function getPage(WebsiteRequest $websiteRequest): PicoPage
147148
$this->loadPicoPlugins($pico);
148149

149150
$output = $pico->run();
151+
} catch (Error $e) {
152+
$this->logger->error(
153+
'Twig Error',
154+
[ 'error' => $e->getMessage(),
155+
'file' => $e->getFile(),
156+
'line_number' => $e->getTemplateLine()
157+
]
158+
);
159+
$exception = new PicoRuntimeException($e);
160+
throw $exception;
150161
} catch (WebsiteInvalidFilesystemException $e) {
151162
throw $e;
152163
} catch (InvalidPathException | NotFoundException | NotPermittedException $e) {

0 commit comments

Comments
 (0)