Skip to content

Commit 7eeea1a

Browse files
authored
Merge pull request #82 from tekktrik/dev/error-passthrough
Pass response via HttpError
2 parents 5858a2f + ca05c02 commit 7eeea1a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

adafruit_portalbase/network.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@
7272
class HttpError(Exception):
7373
"""HTTP Specific Error"""
7474

75+
def __init__(self, message="", response=None):
76+
if message != "":
77+
super().__init__(message)
78+
else:
79+
super().__init__()
80+
self.response = response
81+
7582

7683
class NetworkBase:
7784
"""Network Base Class for the Portal-style libraries.
@@ -282,7 +289,8 @@ def wget(self, url, filename, *, chunk_size=12000, headers=None):
282289
raise HttpError(
283290
"Code {}: {}".format(
284291
response.status_code, response.reason.decode("utf-8")
285-
)
292+
),
293+
response,
286294
)
287295

288296
if self._debug:
@@ -554,7 +562,8 @@ def check_response(self, response):
554562
raise HttpError(
555563
"Code {}: {}".format(
556564
response.status_code, response.reason.decode("utf-8")
557-
)
565+
),
566+
response,
558567
)
559568

560569
return content_type

0 commit comments

Comments
 (0)