diff --git a/Validator/Constraints/TwigSandboxValidator.php b/Validator/Constraints/TwigSandboxValidator.php index 24a3b39..04d6e51 100644 --- a/Validator/Constraints/TwigSandboxValidator.php +++ b/Validator/Constraints/TwigSandboxValidator.php @@ -45,5 +45,16 @@ public function validate($value, Constraint $constraint) '{{ syntax_error }}' => $message, )); } + catch (\Error $e) { + goto ex_r; + } + catch (\Exception $e) { + ex_r: + $message = mb_strlen($e->getMessage()) > 150 ? mb_substr($e->getMessage(), 0, 150) . '…' : $e->getMessage(); + + $this->context->addViolation($constraint->message, array( + '{{ syntax_error }}' => $message, + )); + } } } \ No newline at end of file