Add method not allowed exception
This commit is contained in:
parent
517dd3c38f
commit
f3ba74fe4a
|
@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
|||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.context.request.ServletWebRequest;
|
||||
import org.springframework.web.context.request.WebRequest;
|
||||
import org.springframework.web.servlet.resource.NoResourceFoundException;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -42,6 +43,11 @@ public class ServiceExceptionHandler {
|
|||
return this.handleException(message, request, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@ExceptionHandler(NoResourceFoundException.class)
|
||||
public ResponseEntity<ErrorResponse> handleNoResourceFoundExceptions(NoResourceFoundException e, WebRequest request) {
|
||||
return this.handleException(e.getMessage(), request, HttpStatus.METHOD_NOT_ALLOWED);
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResponseEntity<ErrorResponse> handleAllOtherExceptions(Exception e, WebRequest request) {
|
||||
e.printStackTrace();
|
||||
|
|
Loading…
Reference in New Issue