aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-01-11 15:00:58 +0300
committerGravatar Vitaly Takmazov2017-01-11 15:49:36 +0300
commit14940bf9bf63b1ca8d7d09fde37be52c9ae94ca8 (patch)
tree8be69ea1ccca2e105217440d93d66cb5d3c67661 /juick-www/src
parent2d00d2a39571ad47de229783e6e5fb4cddfe9df2 (diff)
juick-www: handle UserThread exceptions
Diffstat (limited to 'juick-www/src')
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/UserThread.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/juick-www/src/main/java/com/juick/www/controllers/UserThread.java b/juick-www/src/main/java/com/juick/www/controllers/UserThread.java
index 4020e149..5765e02d 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/UserThread.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/UserThread.java
@@ -19,12 +19,16 @@ package com.juick.www.controllers;
import com.juick.Message;
import com.juick.server.helpers.TagStats;
+import com.juick.server.util.HttpNotFoundException;
import com.juick.service.MessagesService;
import com.juick.service.TagService;
import com.juick.service.UserService;
import com.juick.util.MessageUtils;
import com.juick.www.WebApp;
+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.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -68,6 +72,10 @@ public class UserThread {
com.juick.Message msg = messagesService.getMessage(mid);
+ if (msg == null) {
+ throw new HttpNotFoundException();
+ }
+
boolean listview = false;
String paramView = request.getParameter("view");
if (paramView != null) {
@@ -108,6 +116,12 @@ public class UserThread {
}
}
+ // when message id is not fit to int
+ @ExceptionHandler(NumberFormatException.class)
+ public ResponseEntity<String> notfound() {
+ return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+ }
+
public com.juick.Message printMessage(PrintWriter out, com.juick.Message msg, com.juick.User visitor) {
msg.VisitorCanComment = visitor.getUid() > 0;