Class ExceptionAdvice
java.lang.Object
info.ejava.examples.svc.httpapi.gestures.controllers.ExceptionAdvice
@RestControllerAdvice(basePackageClasses=GesturesController.class)
public class ExceptionAdvice
extends Object
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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.springframework.http.ResponseEntity
<String> buildResponse
(org.springframework.http.HttpStatus status, String text) org.springframework.http.ResponseEntity
<String> org.springframework.http.ResponseEntity
<String> org.springframework.http.ResponseEntity
<String> org.springframework.http.ResponseEntity
<String>
-
Constructor Details
-
ExceptionAdvice
public ExceptionAdvice()
-
-
Method Details
-
handle
@ExceptionHandler(NotFoundException.class) public org.springframework.http.ResponseEntity<String> handle(ClientErrorException.NotFoundException ex) -
handle
@ExceptionHandler(InvalidInputException.class) public org.springframework.http.ResponseEntity<String> handle(ClientErrorException.InvalidInputException ex) -
handle
@ExceptionHandler(InternalErrorException.class) public org.springframework.http.ResponseEntity<String> handle(ServerErrorException.InternalErrorException ex) -
handleRuntimeException
@ExceptionHandler(java.lang.RuntimeException.class) public org.springframework.http.ResponseEntity<String> handleRuntimeException(RuntimeException ex) -
buildResponse
-