title: Spring boot handle type mismatch errors
body: <p>I'm using Spring Boot 2.1.5, and I have a class that is mapped to data submitted from a form. The class has an integer field:</p>
  
  <pre><code>class FormData {
     private Integer id;
     ...
  }
  </code></pre>
  
  <p>When I send a payload with the wrong type, e.g:</p>
  
  <pre><code>{
    id: "aaaa"
  }
  </code></pre>
  
  <p>Spring silently returns a 400 status, no exception is thrown, and nothing is printed to the console. I would like to somehow catch this when this happens, so that I would be able to return a proper custom error. I basically use bean validation for all of my other validations, but I can't find a way to apply it for a type mismatch.</p>
  
  <p>Thanks.   </p>