Skip to content

Commit bad80de

Browse files
authored
Merge pull request #448 from TotallyNotRobots/reddit-ignore-404-403
Don't log 404/403 errors when looking up subreddit info
2 parents a1581ea + 0c14b80 commit bad80de

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

plugins/reddit_info.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,12 @@ def get_sub_data(url, sub, reply):
310310
try:
311311
r.raise_for_status()
312312
except HTTPError as e:
313-
reply(statuscheck(e.response.status_code, "r/" + sub))
314-
raise
313+
code = e.response.status_code
314+
reply(statuscheck(code, "r/" + sub))
315+
if code not in (404, 403):
316+
raise
317+
318+
return None
315319

316320
return r.json()
317321

@@ -322,6 +326,9 @@ def submods(text, chan, conn, reply):
322326
sub = get_sub(text)
323327
url = subreddit_url + "about/moderators.json"
324328
data = get_sub_data(url, sub, reply)
329+
if data is None:
330+
return None
331+
325332
moderators = []
326333
for mod in data["data"]["children"]:
327334
username = mod["name"]
@@ -349,8 +356,12 @@ def subinfo(text, reply):
349356
sub = get_sub(text)
350357
url = subreddit_url + "about.json"
351358
data = get_sub_data(url, sub, reply)
359+
if data is None:
360+
return None
361+
352362
if data["kind"] == "Listing":
353363
return "It appears r/{} does not exist.".format(sub)
364+
354365
name = data["data"]["display_name"]
355366
title = data["data"]["title"]
356367
nsfw = data["data"]["over18"]

0 commit comments

Comments
 (0)