feat: meaningful error message for bad credentials
This commit is contained in:
1 file changed
+17
-8
+17
-8
@@ -1,5 +1,7 @@
|
||||
import re
|
||||
|
||||
from prawcore.exceptions import ResponseException
|
||||
|
||||
from utils import settings
|
||||
import praw
|
||||
from praw.models import MoreComments
|
||||
@@ -29,14 +31,21 @@ def get_subreddit_threads(POST_ID: str):
|
||||
username = settings.config["reddit"]["creds"]["username"]
|
||||
if str(username).casefold().startswith("u/"):
|
||||
username = username[2:]
|
||||
reddit = praw.Reddit(
|
||||
client_id=settings.config["reddit"]["creds"]["client_id"],
|
||||
client_secret=settings.config["reddit"]["creds"]["client_secret"],
|
||||
user_agent="Accessing Reddit threads",
|
||||
username=username,
|
||||
passkey=passkey,
|
||||
check_for_async=False,
|
||||
)
|
||||
try:
|
||||
reddit = praw.Reddit(
|
||||
client_id=settings.config["reddit"]["creds"]["client_id"],
|
||||
client_secret=settings.config["reddit"]["creds"]["client_secret"],
|
||||
user_agent="Accessing Reddit threads",
|
||||
username=username,
|
||||
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...")
|
||||
|
||||
Reference in new issue
Block a user