Add plain-language context to error notifications - #1020
Open
FlatterAtMainz wants to merge 2 commits into
Open
Conversation
Errors surfaced through handleException often ended up either blank or as a bare technical fragment (e.g. "Could not load your profile" with no explanation, or a raw "SyntaxError: JSON.parse: unexpected end of input"). Add a humanizeError util that recognises common failure shapes (invalid/empty JSON responses, network failures, expired/revoked OAuth grants, known HTTP status codes) and prefixes the description with a plain-language explanation, applied centrally in the HANDLE_EXCEPTION handler so every existing call site benefits. Also: - handleException now falls back to a plain Error object's .message for the description, and no longer throws when data.error is undefined (message derivation had the same unguarded access). - Wrap the JSON.parse of xhr.responseText in HANDLE_EXCEPTION in a try/catch - a non-JSON error response would otherwise throw inside the exception handler itself. - Spotify getMe() and refreshToken() failures now get specific messages pointing at expired/revoked authorization, since that was the actual root cause behind the vague errors we hit in practice. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
jaedb
requested changes
Aug 4, 2026
jaedb
left a comment
Owner
There was a problem hiding this comment.
Nice work! Would be great to explore the viability of moving these human-friendly errors into the translation file, making it accessible for translation.
Comment on lines
125
to
+336
| @@ -329,8 +331,9 @@ export function getMe() { | |||
| }, | |||
| (error) => { | |||
| dispatch(coreActions.handleException( | |||
| 'Could not load your profile', | |||
| 'Could not load your Spotify profile', | |||
| error, | |||
| 'This usually means your Spotify authorization has expired or is invalid. Try reconnecting Spotify in Settings.', | |||
Owner
There was a problem hiding this comment.
These human-friendly errors would be great to have in the translation file
| if (data.message) { | ||
| message = data.message; | ||
| } else if (data.error.message) { | ||
| } else if (data.error && data.error.message) { |
Owner
There was a problem hiding this comment.
This could simply be data.error?.message, no?
Comment on lines
+3
to
+13
| 0: 'Could not reach the server. Check your network connection, or that the server is running.', | ||
| 400: 'The request was invalid or rejected by the server.', | ||
| 401: 'You are not authenticated, or your session has expired.', | ||
| 403: 'You do not have permission to do that.', | ||
| 404: 'The requested resource could not be found. It may have been removed or renamed.', | ||
| 408: 'The request timed out.', | ||
| 429: 'Too many requests were sent in a short period. Wait a moment and try again.', | ||
| 500: 'The server encountered an internal error.', | ||
| 502: 'The server is temporarily unavailable (bad gateway).', | ||
| 503: 'The server is temporarily unavailable.', | ||
| 504: 'The server took too long to respond (gateway timeout).', |
Owner
There was a problem hiding this comment.
These too, could be in the translation file. It may be tricky, given the execution level to apply the t() method though.
… optional chaining - Humanized error explanations now live under errors.* in en.yaml (via i18n()) instead of being hardcoded in JS, so they're translatable like the rest of the UI. - Replace `x && x.y` null checks with optional chaining per review feedback.
Author
|
Thanks for the review! Pushed
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Errors surfaced through handleException often ended up either blank or as a bare technical fragment (e.g. "Could not load your profile" with no explanation, or a raw "SyntaxError: JSON.parse: unexpected end of input"). Add a humanizeError util that recognises common failure shapes (invalid/empty JSON responses, network failures, expired/revoked OAuth grants, known HTTP status codes) and prefixes the description with a plain-language explanation, applied centrally in the HANDLE_EXCEPTION handler so every existing call site benefits.
Also: