Catch more errors of twig labels

This commit is contained in:
Jan Böhmer 2026-02-15 14:11:31 +01:00
parent 1c6bf3f472
commit 5e9f7a11a3
2 changed files with 3 additions and 4 deletions

View file

@ -42,15 +42,14 @@ declare(strict_types=1);
namespace App\Exceptions; namespace App\Exceptions;
use RuntimeException; use RuntimeException;
use Twig\Error\Error;
class TwigModeException extends RuntimeException class TwigModeException extends RuntimeException
{ {
private const PROJECT_PATH = __DIR__ . '/../../'; 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);
} }
/** /**

View file

@ -95,7 +95,7 @@ final class LabelHTMLGenerator
'paper_height' => $options->getHeight(), 'paper_height' => $options->getHeight(),
] ]
); );
} catch (Error $exception) { } catch (\Throwable $exception) {
throw new TwigModeException($exception); throw new TwigModeException($exception);
} }
} else { } else {