symfony/symfony — pull request #12052 by webmozart (2014-09-26 10:48:27+00:00)
Title: [Validator] Made it possible to store the cause of a constraint violation

| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | yes
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | TODO

This change makes it possible to store the cause of a violation (e.g. an exception). This way it is possible to follow the trace of violations caused by exception up to their root.

```php
try {
// ...
} catch (Exception $e) {
$this->context->buildViolation('Error!')
->setCause($e)
->addViolation();
}
```

This is one step to solve #5607.