Skip to content

Instantly share code, notes, and snippets.

@namila007
Created March 31, 2019 16:07
Show Gist options
  • Save namila007/a3d594354bca66c7e6d4fd88176164fb to your computer and use it in GitHub Desktop.
Save namila007/a3d594354bca66c7e6d4fd88176164fb to your computer and use it in GitHub Desktop.
handle constrain
@ExceptionHandler(ConstraintViolationException.class)
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
public ResponseEntity<Object> handleConstraintViolationException( ConstraintViolationException e )
{
ApiError apiError = createError( MESSAGE_FOR_INVALID_PARAMETERS_ERROR, HttpStatus.BAD_REQUEST, e );
return new ResponseEntity<>( apiError, apiError.getStatus() );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment