feat: meaningful error message for bad credentials

pull/1138/head
Callum Leslie 2 years ago
parent 66ec9b34d2
commit 71c317da23
No known key found for this signature in database
GPG Key ID: D382C4AFEECEAA90

@ -1,5 +1,7 @@
import re
from prawcore.exceptions import ResponseException
from utils import settings
import praw
from praw.models import MoreComments
@ -29,6 +31,7 @@ def get_subreddit_threads(POST_ID: str):
username = settings.config["reddit"]["creds"]["username"]
if str(username).casefold().startswith("u/"):
username = username[2:]
try:
reddit = praw.Reddit(
client_id=settings.config["reddit"]["creds"]["client_id"],
client_secret=settings.config["reddit"]["creds"]["client_secret"],
@ -37,6 +40,12 @@ def get_subreddit_threads(POST_ID: str):
passkey=passkey,
check_for_async=False,
)
except ResponseException as e:
match e.response.status_code:
case 401:
print("Invalid credentials - please check them in config.toml")
except:
print("Something went wrong...")
# Ask user for subreddit input
print_step("Getting subreddit threads...")

Loading…
Cancel
Save