tweaking network error handling, updating ci

This commit is contained in:
Andy Pack 2022-12-20 18:00:52 +00:00
parent 9212a0a4ce
commit 98debaf22a
Signed by: sarsoo
GPG Key ID: A55BA3536A5E0ED7
2 changed files with 12 additions and 9 deletions

View File

@ -6,20 +6,20 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
python-version: [3.8] python-version: [3.10]
poetry-version: [1.1.4] poetry-version: [1.3.1]
os: [ubuntu-20.04, macos-latest, windows-latest] os: [ubuntu-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 # get source - uses: actions/checkout@v3 # get source
- name: Install Python 3 - name: Install Python 3
uses: actions/setup-python@v2 uses: actions/setup-python@v4
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
- name: Install Poetry # dependency management - name: Install Poetry # dependency management
uses: abatilo/actions-poetry@v2.1.0 uses: abatilo/actions-poetry@v2.1.6
with: with:
poetry-version: ${{ matrix.poetry-version }} poetry-version: ${{ matrix.poetry-version }}

View File

@ -170,9 +170,12 @@ class Network:
logger.critical(f'{method} {url_path or whole_url} refresh token limit (5) reached') logger.critical(f'{method} {url_path or whole_url} refresh token limit (5) reached')
try: try:
error_json = response.json()["error"] error_json = response.json()
logger.error(f'{method} {response.status_code} {error_json["message"]}') error_message = error_json.get("error", {}).get("message", error_json)
raise SpotifyNetworkException(http_code=response.status_code, message=error_json["message"])
logger.error(f'{method} {response.status_code} {error_message}')
raise SpotifyNetworkException(http_code=response.status_code, message=error_message)
except (KeyError, JSONDecodeError): except (KeyError, JSONDecodeError):
logger.error(f'{method} {response.status_code} no error object found') logger.error(f'{method} {response.status_code} no error object found')
raise SpotifyNetworkException(http_code=response.status_code, message=response.text) raise SpotifyNetworkException(http_code=response.status_code, message=response.text)