Skip to content

Commit 7a25d8b

Browse files
committed
handled json decode error
1 parent d51960f commit 7a25d8b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/login.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from requests import Session
2+
from requests.exceptions import JSONDecodeError
23
from bs4 import BeautifulSoup, Tag
34
import re
45
from typing import Any
@@ -46,7 +47,15 @@ def login_with_drexel_connect(session: Session) -> Session:
4647
assert (
4748
response.status_code == 200
4849
), "Failed to request MFA code page from Drexel Connect"
49-
json_response = response.json()
50+
51+
try:
52+
json_response = response.json()
53+
except JSONDecodeError:
54+
raise Exception(
55+
"Failed to decode JSON response from Drexel Connect. Response: {}".format(
56+
response.text
57+
)
58+
)
5059

5160
data = {
5261
json_response["csrfN"]: json_response["csrfV"],

0 commit comments

Comments
 (0)