Skip to content

Commit

Permalink
use repr for error causes
Browse files Browse the repository at this point in the history
  • Loading branch information
grqx committed Dec 27, 2024
1 parent 54b9255 commit 11e15ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions plugin/yt_dlp_plugins/extractor/getpot_bgutil_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ def _validate_get_pot(self, client: str, ydl: YoutubeDL, visitor_data=None, data
f'{base_url}/ping', extensions={'timeout': 5.0}, proxies={'all': None}))
except Exception as e:
raise UnsupportedRequest(
f'Error reaching GET /ping (caused by {e!s})') from e
f'Error reaching GET /ping (caused by {e!r})') from e
try:
response = json.load(response)
except json.JSONDecodeError as e:
raise UnsupportedRequest(
f'Error parsing response JSON (caused by {e!s})'
f'Error parsing response JSON (caused by {e!r})'
f', response: {response.read()}') from e
if response.get('version') != self.VERSION:
self._logger.warning(
Expand Down Expand Up @@ -75,13 +75,13 @@ def _get_pot(self, client: str, ydl: YoutubeDL, visitor_data=None, data_sync_id=
extensions={'timeout': 20.0}, proxies={'all': None}))
except Exception as e:
raise RequestError(
f'Error reaching POST /get_pot (caused by {e!s})') from e
f'Error reaching POST /get_pot (caused by {e!r})') from e

try:
response_json = json.load(response)
except Exception as e:
raise RequestError(
f'Error parsing response JSON (caused by {e!s}). response = {response.read().decode()}') from e
f'Error parsing response JSON (caused by {e!r}). response = {response.read().decode()}') from e

if error_msg := response_json.get('error'):
raise RequestError(error_msg)
Expand Down
2 changes: 1 addition & 1 deletion plugin/yt_dlp_plugins/extractor/getpot_bgutil_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _get_pot(self, client: str, ydl: YoutubeDL, visitor_data=None, data_sync_id=
script_data_resp = json.loads(stdout.splitlines()[-1])
except json.JSONDecodeError as e:
raise RequestError(
f'Error parsing JSON response from _get_pot_via_script (caused by {e!s})') from e
f'Error parsing JSON response from _get_pot_via_script (caused by {e!r})') from e
else:
self._logger.debug(
f'_get_pot_via_script response = {script_data_resp}')
Expand Down

0 comments on commit 11e15ce

Please sign in to comment.