1 package civitas.bboard.server.controllers;
2
3 import org.springframework.http.HttpHeaders;
4 import org.springframework.http.HttpStatus;
5 import org.springframework.http.ResponseEntity;
6 import org.springframework.web.bind.annotation.ControllerAdvice;
7 import org.springframework.web.bind.annotation.ExceptionHandler;
8 import org.springframework.web.context.request.WebRequest;
9 import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
10
11 @ControllerAdvice
12 public class CommunicableExceptionHandler extends ResponseEntityExceptionHandler {
13
14 @ExceptionHandler(CommunicableException.class)
15 ResponseEntity<Object> handleException(final CommunicableException ex, final WebRequest request) {
16 return super.handleExceptionInternal(ex, ex.getMessage(), new HttpHeaders(), HttpStatus.BAD_REQUEST, request);
17 }
18 }