Package info.ejava.examples.common.web
Class BaseExceptionAdvice
java.lang.Object
info.ejava.examples.common.web.BaseExceptionAdvice
- Direct Known Subclasses:
ExceptionAdvice
,ExceptionAdvice
,ExceptionAdvice
,ExceptionAdvice
,ExceptionAdvice
,ExceptionAdvice
,ExceptionAdvice
,ExceptionAdvice
,HousesExceptionAdvice
,RentersExceptionAdvice
This class provide custom error handling for exceptions thrown by the
controller. It is one of several techniques offered by Spring and
selected primarily because we retain full control over the response
and response headers returned to the caller.
Extend this class and declare the
@RestController
on the child class in your module:
@RestControllerAdvice(assignableTypes = MyController.class)
public class MyExceptionAdvice extends BaseExceptionAdvice {}
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.springframework.http.ResponseEntity
<MessageDTO> buildResponse
(org.springframework.http.HttpStatus status, String error, String text, Instant timestamp) protected String
protected String
org.springframework.http.ResponseEntity
<MessageDTO> org.springframework.http.ResponseEntity
<MessageDTO> org.springframework.http.ResponseEntity
<MessageDTO> org.springframework.http.ResponseEntity
<MessageDTO> org.springframework.http.ResponseEntity
<MessageDTO> org.springframework.http.ResponseEntity
<MessageDTO> org.springframework.http.ResponseEntity
<MessageDTO> handle
(org.springframework.security.access.AccessDeniedException ex) org.springframework.http.ResponseEntity
<MessageDTO>
-
Constructor Details
-
BaseExceptionAdvice
public BaseExceptionAdvice()
-
-
Method Details
-
handle
@ExceptionHandler(NotFoundException.class) public org.springframework.http.ResponseEntity<MessageDTO> handle(ClientErrorException.NotFoundException ex) -
handle
@ExceptionHandler(java.util.NoSuchElementException.class) public org.springframework.http.ResponseEntity<MessageDTO> handle(NoSuchElementException ex) -
handle
@ExceptionHandler(InvalidInputException.class) public org.springframework.http.ResponseEntity<MessageDTO> handle(ClientErrorException.InvalidInputException ex) -
handle
@ExceptionHandler(BadRequestException.class) public org.springframework.http.ResponseEntity<MessageDTO> handle(ClientErrorException.BadRequestException ex) -
handle
@ExceptionHandler(NotAuthorizedException.class) public org.springframework.http.ResponseEntity<MessageDTO> handle(ClientErrorException.NotAuthorizedException ex) -
handle
@ExceptionHandler(InternalErrorException.class) public org.springframework.http.ResponseEntity<MessageDTO> handle(ServerErrorException.InternalErrorException ex) -
handle
@ExceptionHandler(org.springframework.security.access.AccessDeniedException.class) public org.springframework.http.ResponseEntity<MessageDTO> handle(org.springframework.security.access.AccessDeniedException ex) -
handleRuntimeException
@ExceptionHandler(java.lang.RuntimeException.class) public org.springframework.http.ResponseEntity<MessageDTO> handleRuntimeException(RuntimeException ex) -
buildResponse
protected org.springframework.http.ResponseEntity<MessageDTO> buildResponse(org.springframework.http.HttpStatus status, String error, String text, Instant timestamp) -
getPrincipal
-
getMethod
-