Class ValidationErrorsHandler
- java.lang.Object
-
- cz.zcu.students.cacha.bp_server.error.ValidationErrorsHandler
-
@RestControllerAdvice public class ValidationErrorsHandler extends Object
Class for handling errors
-
-
Constructor Summary
Constructors Constructor Description ValidationErrorsHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ApiError
handleCustomValidationException(ValidationErrorException exception, javax.servlet.http.HttpServletRequest request)
Gets the response for ValidationErrorException custom exceptionApiError
handleException(Exception exception, javax.servlet.http.HttpServletRequest request)
Handles named custom exceptionApiError
handleValidationException(org.springframework.web.bind.MethodArgumentNotValidException exception, javax.servlet.http.HttpServletRequest request)
Gets the response for MethodArgumentNotValidException
-
-
-
Method Detail
-
handleValidationException
@ExceptionHandler(org.springframework.web.bind.MethodArgumentNotValidException.class) @ResponseStatus(BAD_REQUEST) public ApiError handleValidationException(org.springframework.web.bind.MethodArgumentNotValidException exception, javax.servlet.http.HttpServletRequest request)
Gets the response for MethodArgumentNotValidException- Parameters:
exception
- MethodArgumentNotValidExceptionrequest
- http request- Returns:
- api error response
-
handleCustomValidationException
@ExceptionHandler(ValidationErrorException.class) @ResponseStatus(BAD_REQUEST) public ApiError handleCustomValidationException(ValidationErrorException exception, javax.servlet.http.HttpServletRequest request)
Gets the response for ValidationErrorException custom exception- Parameters:
exception
- ValidationErrorExceptionrequest
- http request- Returns:
- api error response
-
handleException
@ExceptionHandler({CannotPerformActionException.class,CannotSaveImageException.class,NotFoundException.class,UnauthorizedException.class}) @ResponseStatus(BAD_REQUEST) public ApiError handleException(Exception exception, javax.servlet.http.HttpServletRequest request)
Handles named custom exception- Parameters:
exception
- Exceptionrequest
- http request- Returns:
- api error response
-
-