Skip to content

Commit

Permalink
Merge pull request #4 from slashliv/fix-catch_error
Browse files Browse the repository at this point in the history
The message for critical errors has been changed
  • Loading branch information
muxx authored Oct 10, 2016
2 parents ed1fdbd + bbda1b8 commit aab46bd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
1 change: 1 addition & 0 deletions Validator/Constraints/TwigSandbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
5 changes: 1 addition & 4 deletions Validator/Constraints/TwigSandboxValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

0 comments on commit aab46bd

Please sign in to comment.