36 lines
1.2 KiB
Java
36 lines
1.2 KiB
Java
/**
|
|
*
|
|
*/
|
|
package de.bstly.board.controller.support;
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
import org.springframework.web.context.request.WebRequest;
|
|
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
|
|
|
|
|
|
/**
|
|
* The Class ControllerExceptionHandler.
|
|
*/
|
|
@ControllerAdvice
|
|
public class ControllerExceptionHandler extends ResponseEntityExceptionHandler {
|
|
|
|
/**
|
|
* Handle response entity status exception.
|
|
*
|
|
* @param exception the exception
|
|
* @param request the request
|
|
* @return the response entity
|
|
*/
|
|
@ExceptionHandler(value = { EntityResponseStatusException.class })
|
|
protected ResponseEntity<Object> handleResponseEntityStatusException(RuntimeException exception,
|
|
WebRequest request) {
|
|
EntityResponseStatusException entityResponseStatusException = (EntityResponseStatusException) exception;
|
|
return handleExceptionInternal(exception, entityResponseStatusException.getBody(),
|
|
new HttpHeaders(), entityResponseStatusException.getStatus(), request);
|
|
}
|
|
|
|
}
|