From b02305585e311b657bb55bc4103bd6fc7ebfcd22 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Wed, 17 Mar 2021 09:13:51 +0400 Subject: [PATCH] #1 -- Fix code --- .../extractor/mvc/GitExtractorController.java | 17 ----------------- .../mvc/GlobalDefaultExceptionHandler.java | 10 ---------- 2 files changed, 27 deletions(-) diff --git a/src/main/java/ru/ulstu/extractor/mvc/GitExtractorController.java b/src/main/java/ru/ulstu/extractor/mvc/GitExtractorController.java index 6b02876..487479c 100644 --- a/src/main/java/ru/ulstu/extractor/mvc/GitExtractorController.java +++ b/src/main/java/ru/ulstu/extractor/mvc/GitExtractorController.java @@ -1,18 +1,12 @@ package ru.ulstu.extractor.mvc; -import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.servlet.ModelAndView; import ru.ulstu.extractor.mvc.model.EmailForm; -import javax.servlet.http.HttpServletRequest; - @Controller public class GitExtractorController { @GetMapping("/") @@ -29,15 +23,4 @@ public class GitExtractorController { } return "result"; } - - - @ExceptionHandler(Exception.class) - @ResponseStatus(HttpStatus.NOT_FOUND) - public ModelAndView handleResourceNotFoundException(HttpServletRequest req, Exception ex) { - ModelAndView mav = new ModelAndView(); - mav.addObject("exception", ex); - mav.addObject("url", req.getRequestURL()); - mav.setViewName("error"); - return mav; - } } diff --git a/src/main/java/ru/ulstu/extractor/mvc/GlobalDefaultExceptionHandler.java b/src/main/java/ru/ulstu/extractor/mvc/GlobalDefaultExceptionHandler.java index 022764f..7a1ea5b 100644 --- a/src/main/java/ru/ulstu/extractor/mvc/GlobalDefaultExceptionHandler.java +++ b/src/main/java/ru/ulstu/extractor/mvc/GlobalDefaultExceptionHandler.java @@ -15,16 +15,6 @@ class GlobalDefaultExceptionHandler { @ExceptionHandler(value = Exception.class) public ModelAndView defaultErrorHandler(HttpServletRequest req, Exception e) { - // If the exception is annotated with @ResponseStatus rethrow it and let - // the framework handle it - like the OrderNotFoundException example - // at the start of this post. - // AnnotationUtils is a Spring Framework utility class. - /*if (AnnotationUtils.findAnnotation (e.getClass(), ResponseStatus.class) != null) { - throw e; - } - */ - - // Otherwise setup and send the user to a default error-view. ModelAndView mav = new ModelAndView(); mav.addObject("exception", e); mav.addObject("url", req.getRequestURL());