T203 added javadoc
This commit is contained in:
		@@ -10,10 +10,20 @@ import javax.validation.ConstraintViolationException;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
//TODO: Find usage and document or remove it
 | 
			
		||||
//TODO: Is it really necessary?
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Custom exception handler for {@link ConstraintViolationException}
 | 
			
		||||
 * @author Rafał Żukowicz
 | 
			
		||||
 */
 | 
			
		||||
@ControllerAdvice
 | 
			
		||||
public class MvcExceptionHandler {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Provides handling for {@link ConstraintViolationException}
 | 
			
		||||
     * @param e exception argument
 | 
			
		||||
     * @return response with error list and status 400 bad request
 | 
			
		||||
     */
 | 
			
		||||
    @ExceptionHandler(ConstraintViolationException.class)
 | 
			
		||||
    public ResponseEntity<List> validationErrorHandler(ConstraintViolationException e){
 | 
			
		||||
        List<String> errors = new ArrayList<>(e.getConstraintViolations().size());
 | 
			
		||||
@@ -24,6 +34,11 @@ public class MvcExceptionHandler {
 | 
			
		||||
        return new ResponseEntity<>(errors, HttpStatus.BAD_REQUEST);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Provides handling for {@link BindException}
 | 
			
		||||
     * @param ex exception argument
 | 
			
		||||
     * @return response with error list and status 400 bad request
 | 
			
		||||
     */
 | 
			
		||||
    @ExceptionHandler(BindException.class)
 | 
			
		||||
    public ResponseEntity<List> handleBindException(BindException ex){
 | 
			
		||||
        return new ResponseEntity(ex.getAllErrors(), HttpStatus.BAD_REQUEST);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user