diff --git a/Validator/Constraints/TwigSandbox.php b/Validator/Constraints/TwigSandbox.php index 4b7814d..838b3e9 100644 --- a/Validator/Constraints/TwigSandbox.php +++ b/Validator/Constraints/TwigSandbox.php @@ -10,6 +10,7 @@ class TwigSandbox extends Constraint { public $message = 'This value is not a valid Twig template. The parsing error is: {{ syntax_error }}'; + public $criticalErrorMessage = 'Critical error occurred while rendering the template. Please check the correctness of template syntax.'; public function validatedBy() { diff --git a/Validator/Constraints/TwigSandboxValidator.php b/Validator/Constraints/TwigSandboxValidator.php index 04d6e51..d5afe2c 100644 --- a/Validator/Constraints/TwigSandboxValidator.php +++ b/Validator/Constraints/TwigSandboxValidator.php @@ -50,11 +50,8 @@ public function validate($value, Constraint $constraint) } 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, - )); + $this->context->addViolation($constraint->criticalErrorMessage); } } } \ No newline at end of file