Class ControllerExceptionHandler
- java.lang.Object
-
- org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
-
- io.github.astrapi69.spring.exceptionhandling.ControllerExceptionHandler
-
@ControllerAdvice(annotations=org.springframework.web.bind.annotation.RestController.class) public class ControllerExceptionHandler extends org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandlerThe classControllerExceptionHandlerhandles specified exceptions for rest controllers
-
-
Constructor Summary
Constructors Constructor Description ControllerExceptionHandler(org.springframework.context.MessageSource messageSource)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.springframework.http.ResponseEntity<java.lang.Object>handleBindException(org.springframework.validation.BindException exception, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)org.springframework.http.ResponseEntity<java.lang.Object>handleException(java.lang.Exception exception, javax.servlet.http.HttpServletRequest request)Handle all generalExceptionsorg.springframework.http.ResponseEntity<java.lang.Object>handleIllegalArgumentException(java.lang.IllegalArgumentException exception, javax.servlet.http.HttpServletRequest request)Handle allIllegalArgumentExceptionsorg.springframework.http.ResponseEntity<java.lang.Object>handleNoSuchElementException(java.util.NoSuchElementException exception, javax.servlet.http.HttpServletRequest request)Handle allNoSuchElementExceptionsorg.springframework.http.ResponseEntity<java.lang.Object>handleUnsupportedOperationException(java.lang.UnsupportedOperationException exception, javax.servlet.http.HttpServletRequest request)Handle allUnsupportedOperationExceptions-
Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
handleAsyncRequestTimeoutException, handleConversionNotSupported, handleException, handleExceptionInternal, handleHttpMediaTypeNotAcceptable, handleHttpMediaTypeNotSupported, handleHttpMessageNotReadable, handleHttpMessageNotWritable, handleHttpRequestMethodNotSupported, handleMethodArgumentNotValid, handleMissingPathVariable, handleMissingServletRequestParameter, handleMissingServletRequestPart, handleNoHandlerFoundException, handleServletRequestBindingException, handleTypeMismatch
-
-
-
-
Method Detail
-
handleBindException
protected org.springframework.http.ResponseEntity<java.lang.Object> handleBindException(org.springframework.validation.BindException exception, org.springframework.http.HttpHeaders headers, org.springframework.http.HttpStatus status, org.springframework.web.context.request.WebRequest request)- Overrides:
handleBindExceptionin classorg.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
-
handleException
@ExceptionHandler(java.lang.Exception.class) public org.springframework.http.ResponseEntity<java.lang.Object> handleException(java.lang.Exception exception, javax.servlet.http.HttpServletRequest request)Handle all generalExceptions- Parameters:
exception- the exceptionrequest- the current request- Returns:
- a
ResponseEntityinstance
-
handleIllegalArgumentException
@ExceptionHandler(java.lang.IllegalArgumentException.class) public org.springframework.http.ResponseEntity<java.lang.Object> handleIllegalArgumentException(java.lang.IllegalArgumentException exception, javax.servlet.http.HttpServletRequest request)Handle allIllegalArgumentExceptions- Parameters:
exception- the exceptionrequest- the current request- Returns:
- a
ResponseEntityinstance
-
handleNoSuchElementException
@ExceptionHandler(java.util.NoSuchElementException.class) public org.springframework.http.ResponseEntity<java.lang.Object> handleNoSuchElementException(java.util.NoSuchElementException exception, javax.servlet.http.HttpServletRequest request)Handle allNoSuchElementExceptions- Parameters:
exception- the exceptionrequest- the current request- Returns:
- a
ResponseEntityinstance
-
handleUnsupportedOperationException
@ExceptionHandler(java.lang.UnsupportedOperationException.class) public org.springframework.http.ResponseEntity<java.lang.Object> handleUnsupportedOperationException(java.lang.UnsupportedOperationException exception, javax.servlet.http.HttpServletRequest request)Handle allUnsupportedOperationExceptions- Parameters:
exception- the exceptionrequest- the current request- Returns:
- a
ResponseEntityinstance
-
-