Skip to content

Commit bd71466

Browse files
authored
chore: update readme to check if response attribute of WebPushException object is not None (#168)
updated README.md and README.rst with check if response attribute of WebPushException is not None (thus is an instance of requests.Response) this is because requests.Response.__bool__ method returns False if the status code is between 400 and 599 which prevents proper error handling if the Response turns out to be falsy
1 parent c99d0f7 commit bd71466

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ try:
103103
except WebPushException as ex:
104104
print("I'm sorry, Dave, but I can't do that: {}", repr(ex))
105105
# Mozilla returns additional information in the body of the response.
106-
if ex.response and ex.response.json():
106+
if ex.response is not None and ex.response.json():
107107
extra = ex.response.json()
108108
print("Remote service replied with a {}:{}, {}",
109109
extra.code,

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ e.g. the output of:
116116
except WebPushException as ex:
117117
print("I'm sorry, Dave, but I can't do that: {}", repr(ex))
118118
# Mozilla returns additional information in the body of the response.
119-
if ex.response and ex.response.json():
119+
if ex.response is not None and ex.response.json():
120120
extra = ex.response.json()
121121
print("Remote service replied with a {}:{}, {}",
122122
extra.code,

0 commit comments

Comments
 (0)