title: Spring ConstraintViolation not caught
body: <p>I'm using Spring Boot, and I have created a custom PathVariable validator, which I use as follows:</p>
  
  <pre><code>@GetMapping(value = "/test/{id}")
  public ResponseEntity&lt;Void&gt; test(@PathVariable("id")
                                       @Valid
                                       @MyGUID(message = "ID_INVALID")
                                               String id) {
  
      return new ResponseEntity&lt;&gt;(HttpStatus.NO_CONTENT);
  }
  </code></pre>
  
  <p>The validor seems to do its job well - it passes when input is valid, and throws exception when not. The problem is, that my custom exception handler doesn't catch the <code>ConstraintViolationException</code> that is thrown. This is the top line of the stack trace:</p>
  
  <pre><code>javax.validation.ConstraintViolationException: ID_INVALID 
  </code></pre>
  
  <p>Then I have my exeception handler class:</p>
  
  <pre><code>@ControllerAdvice
  public class RestExceptionController extends ResponseEntityExceptionHandler {
  
      @ExceptionHandler(value = ConstraintViolationException.class)
  public ResponseEntity&lt;ErrorResponse&gt; handleConstraintViolationException(ConstraintViolationException ex,
                                                                          HttpHeaders headers,
                                                                          HttpStatus status,
                                                                          WebRequest request) {
      List&lt;String&gt; errorDetailsCodes = new ArrayList&lt;&gt;();
  
      for (ConstraintViolation&lt;?&gt; violation : ex.getConstraintViolations()) {
          errorDetailsCodes.add(violation.getMessage());
      }
  
      ErrorResponse errorResponse = new ErrorResponse(
              status.name(),
              status.value(),
              ex.hashCode(),
              errorDetailsCodes
      );
  
      logException(ex);
  
      return new ResponseEntity&lt;&gt;(errorResponse, headers, status);
  }
  
  @ExceptionHandler(value = Exception.class)
  public ResponseEntity&lt;ErrorResponse&gt; handleGeneralException(Exception ex) {
      ErrorResponse errorResponse = new ErrorResponse(
              HttpStatus.INTERNAL_SERVER_ERROR.name(),
              HttpStatus.INTERNAL_SERVER_ERROR.value(),
              ex.hashCode()
      );
  
      logException(ex);
  
      return new ResponseEntity&lt;&gt;(errorResponse, HttpStatus.INTERNAL_SERVER_ERROR);
  }
  }
  </code></pre>
  
  <p>It is strange to me that despite the fact I have both a specific and a general exception handler, they are both skipped, and the system throws its own error:</p>
  
  <pre><code>{
    "timestamp": 1568554746642,
    "status": 500,
    "error": "Internal Server Error",
    "message": "ID_INVALID",
    "path": "/api/logged-in-user/test/123"
  }
  </code></pre>
  
  <p>How can I catch this exception and return my custom response?</p>
  
  <p>Thanks.   </p>