-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #282
- Loading branch information
Showing
10 changed files
with
187 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import logging | ||
|
||
import requests | ||
import httpx | ||
|
||
log = logging.getLogger("RequestException") | ||
log = logging.getLogger("HttpxException") | ||
|
||
|
||
class RequestsException(Exception): | ||
def __init__(self, response: requests.Response) -> None: | ||
class HttpxException(Exception): | ||
def __init__(self, response: httpx.Response) -> None: | ||
self.error_code = response.status_code | ||
self.error_msg = "Something went wrong!" | ||
try: | ||
log.error( | ||
f"The request responded with the code {self.error_code}. Error body: {response.json()}" | ||
) | ||
response.raise_for_status() | ||
except requests.HTTPError as e: | ||
except httpx.HTTPError as e: | ||
self.error_msg = str(e) | ||
log.error(f"More information: {self.error_msg}") | ||
super().__init__() |
Oops, something went wrong.