-
Notifications
You must be signed in to change notification settings - Fork 2k
Improves SubsonicUpdate error messages when server is unavailable #5635 #6197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
30cd320
6e08aa0
a81456a
51be7be
5f1975c
948cdac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -138,21 +138,24 @@ def start_scan(self): | |
| params=payload, | ||
| timeout=10, | ||
| ) | ||
| json = response.json() | ||
|
|
||
| if ( | ||
| response.status_code == 200 | ||
| and json["subsonic-response"]["status"] == "ok" | ||
| ): | ||
| count = json["subsonic-response"]["scanStatus"]["count"] | ||
| self._log.info("Updating Subsonic; scanning {} tracks", count) | ||
| elif ( | ||
| response.status_code == 200 | ||
| and json["subsonic-response"]["status"] == "failed" | ||
| ): | ||
| response.raise_for_status() | ||
| try: | ||
| json = response.json() | ||
| except ValueError: | ||
| self._log.error( | ||
| "Error: {[subsonic-response][error][message]}", json | ||
| "Invalid JSON from Subsonic: {}", response.text[:200] | ||
| ) | ||
| return | ||
| if not (resp := json.get("subsonic-response")): | ||
| self._log.error("Missing 'subsonic-response' field: {}", json) | ||
| return | ||
| status = resp.get("status") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have to be defensive here? The same applies to |
||
| if status == "ok": | ||
| count = resp.get("scanStatus", {}).get("count", 0) | ||
| self._log.info("Updating Subsonic; scanning {} tracks", count) | ||
| elif status == "failed": | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we raise for status, |
||
| msg = resp.get("error", {}).get("message", "Unknown error") | ||
| self._log.error("Error: {}", msg) | ||
| else: | ||
| self._log.error("Error: {}", json) | ||
| except Exception as error: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.