From cedf00d682ef0b62e291f9fec9946162bcdc098e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 30 Oct 2021 05:08:45 +0300 Subject: Handle wrong RSS path correctly --- src/main/java/com/juick/www/rss/Feeds.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/main/java/com/juick') diff --git a/src/main/java/com/juick/www/rss/Feeds.java b/src/main/java/com/juick/www/rss/Feeds.java index 4423b263..8111f2df 100644 --- a/src/main/java/com/juick/www/rss/Feeds.java +++ b/src/main/java/com/juick/www/rss/Feeds.java @@ -22,7 +22,12 @@ import com.juick.util.HttpNotFoundException; import com.juick.service.MessagesService; import com.juick.service.UserService; import com.juick.service.security.annotation.Visitor; + +import org.springframework.core.convert.ConversionFailedException; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; @@ -79,4 +84,9 @@ public class Feeds { modelAndView.addObject("messages", messagesService.getLastReplies(hours)); return modelAndView; } + // wrong feed type + @ExceptionHandler(ConversionFailedException.class) + public ResponseEntity notFoundAction() { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } } -- cgit v1.2.3