source: src/main/java/edu/gjoko/schedlr/config/ExceptionHandlerAdvice.java@ 77205be

Last change on this file since 77205be was 77205be, checked in by gjoko kostadinov <gjokokostadinov@…>, 6 months ago

Add entire code

  • Property mode set to 100755
File size: 882 bytes
Line 
1package edu.gjoko.schedlr.config;
2
3import edu.gjoko.schedlr.exceptions.BlockingTimeException;
4import org.springframework.http.HttpHeaders;
5import org.springframework.http.HttpStatus;
6import org.springframework.http.ResponseEntity;
7import org.springframework.web.bind.annotation.ControllerAdvice;
8import org.springframework.web.bind.annotation.ExceptionHandler;
9import org.springframework.web.context.request.WebRequest;
10import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
11
12@ControllerAdvice
13public class ExceptionHandlerAdvice extends ResponseEntityExceptionHandler {
14
15 @ExceptionHandler(value = BlockingTimeException.class)
16 protected ResponseEntity<Object> handleConflict(RuntimeException ex, WebRequest request) {
17 return handleExceptionInternal(ex, ex.getMessage(), new HttpHeaders(), HttpStatus.CONFLICT, request);
18 }
19}
Note: See TracBrowser for help on using the repository browser.