From 13b56e631620e9f23120dc2facc4e86733f929c0 Mon Sep 17 00:00:00 2001 From: derMart Date: Tue, 13 Dec 2022 11:19:19 +0100 Subject: [PATCH] improve twig error logging Signed-off-by: derMart --- lib/Service/PicoService.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/Service/PicoService.php b/lib/Service/PicoService.php index a9f2090d..92ba8612 100644 --- a/lib/Service/PicoService.php +++ b/lib/Service/PicoService.php @@ -43,6 +43,7 @@ use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OCP\ILogger; +use Twig\Error\Error; class PicoService { @@ -147,6 +148,16 @@ public function getPage(WebsiteRequest $websiteRequest): PicoPage $this->loadPicoPlugins($pico); $output = $pico->run(); + } catch (Error $e) { + $this->logger->error( + 'Twig Error', + [ 'error' => $e->getMessage(), + 'file' => $e->getFile(), + 'line_number' => $e->getTemplateLine() + ] + ); + $exception = new PicoRuntimeException($e); + throw $exception; } catch (WebsiteInvalidFilesystemException $e) { throw $e; } catch (InvalidPathException | NotFoundException | NotPermittedException $e) {