From d2f207a0e07f3f82a784f2ef132a004eaa6a050a Mon Sep 17 00:00:00 2001 From: adb Date: Sat, 30 Jan 2021 23:27:25 +0100 Subject: [PATCH] return error if no subreddit is invalid --- .../java/sh/adb/RandomRedditMemesAPI/CommunityHandler.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/sh/adb/RandomRedditMemesAPI/CommunityHandler.java b/src/main/java/sh/adb/RandomRedditMemesAPI/CommunityHandler.java index 84b2300..6acd752 100644 --- a/src/main/java/sh/adb/RandomRedditMemesAPI/CommunityHandler.java +++ b/src/main/java/sh/adb/RandomRedditMemesAPI/CommunityHandler.java @@ -63,7 +63,10 @@ class CommunityHandler implements HttpHandler { try { submissions = this.api.getSub(pathArray[4]); } catch (RedditParseException e) { + responseJSON.put("error", "invalid subreddit"); + sendResponse(t, responseJSON.toString()); e.printStackTrace(); + return; } assert submissions != null;