From 5e9f7a11a368245a3eaf57a87090519395e22ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 15 Feb 2026 14:11:31 +0100 Subject: [PATCH] Catch more errors of twig labels --- src/Exceptions/TwigModeException.php | 5 ++--- src/Services/LabelSystem/LabelHTMLGenerator.php | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Exceptions/TwigModeException.php b/src/Exceptions/TwigModeException.php index b76d14d3..ea84667a 100644 --- a/src/Exceptions/TwigModeException.php +++ b/src/Exceptions/TwigModeException.php @@ -42,15 +42,14 @@ declare(strict_types=1); namespace App\Exceptions; use RuntimeException; -use Twig\Error\Error; class TwigModeException extends RuntimeException { private const PROJECT_PATH = __DIR__ . '/../../'; - public function __construct(?Error $previous = null) + public function __construct(?\Throwable $previous = null) { - parent::__construct($previous->getMessage(), 0, $previous); + parent::__construct($previous?->getMessage() ?? "Unknown message", 0, $previous); } /** diff --git a/src/Services/LabelSystem/LabelHTMLGenerator.php b/src/Services/LabelSystem/LabelHTMLGenerator.php index 8a5201ff..31093953 100644 --- a/src/Services/LabelSystem/LabelHTMLGenerator.php +++ b/src/Services/LabelSystem/LabelHTMLGenerator.php @@ -95,7 +95,7 @@ final class LabelHTMLGenerator 'paper_height' => $options->getHeight(), ] ); - } catch (Error $exception) { + } catch (\Throwable $exception) { throw new TwigModeException($exception); } } else {