Skip to content

Commit 3c68f4f

Browse files
committed
Added response checks
1 parent 3021f30 commit 3c68f4f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

DisMail/api/secmail/inbox.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ def format_url(action, **kwargs):
1010

1111
def get_inbox(login, domain):
1212
res = requests.get(format_url("getMessages", login=login, domain=domain))
13-
# TODO: Check response
13+
if not res.ok:
14+
raise Exception("Response shows error: " + res.text)
1415

1516
data = res.json()
1617
return data
1718

1819
def read_mail(login, domain, mailid):
1920
res = requests.get(format_url("readMessage", login=login, domain=domain, id=mailid))
20-
# TODO: Check response
21+
if not res.ok:
22+
raise Exception("Response shows error: " + res.text)
2123

2224
data = res.json()
2325
return Mail(mailid=data["id"], sender=data["from"], **data)
@@ -28,7 +30,8 @@ def download_attachment(login, domain, mailid, filename):
2830
format_url("download", login=login, domain=domain, id=mailid, file=filename),
2931
stream=True
3032
)
31-
# TODO: Check response
33+
if not res.ok:
34+
raise Exception("Response shows error: " + res.text)
3235

3336
output = open(f"{os.getcwd()}/{filename}", "wb")
3437

0 commit comments

Comments
 (0)