title: Set http code for Symfony constraint validation failure
body: <p>Shortly: how can you set a specific http error code, instead of a generic 500, when a constraint fails on entity save?</p>
  
  <h1>Details</h1>
  
  <p>I'm using Symfony custom constraint <code>@UniqueEntity</code> (<a href="http://symfony.com/doc/current/reference/constraints/UniqueEntity.html" rel="nofollow">http://symfony.com/doc/current/reference/constraints/UniqueEntity.html</a>) to assert that some data is not duplicated when saving an entity.</p>
  
  <p>If this constraint check results in a violation, I get a 500 http code, while others may be more appropriate, e.g. 409 - Conflict (<a href="https://httpstatuses.com/409" rel="nofollow">https://httpstatuses.com/409</a>).</p>
  
  <p>I can't seem to find any documentation on how to override the validation response.</p>
  
  <p>Thank you in advance for any suggestion.</p>