fix: improve error messaging for YouTube API errors
Some checks failed
Invidious CI / build - crystal: 1.10.1, stable: true (push) Failing after 10s
Invidious CI / build - crystal: 1.11.2, stable: true (push) Failing after 4s
Invidious CI / build - crystal: 1.12.1, stable: true (push) Failing after 4s
Invidious CI / build - crystal: 1.9.2, stable: true (push) Failing after 4s
Invidious CI / build - crystal: nightly, stable: false (push) Failing after 4s
Build and release container directly from master / release (push) Has been cancelled
Invidious CI / build-docker (push) Has been cancelled
Invidious CI / build-docker-arm64 (push) Has been cancelled
Invidious CI / ameba_lint (push) Has been cancelled

Enhanced error handling by adding a specific message for errors returned from YouTube, providing more context to users. This change concatenates a generic YouTube error description to the specific error message, enabling clearer issue identification. This aids in better user guidance during troubleshooting steps.
This commit is contained in:
Kumi 2024-10-19 11:27:33 +02:00
parent 97ab3459b4
commit 8dc6f03ece
Signed by: kumi
GPG key ID: ECBCC9082395383F
2 changed files with 4 additions and 0 deletions

View file

@ -459,6 +459,7 @@
"search_filters_sort_option_views": "View count",
"search_filters_apply_button": "Apply selected filters",
"Current version: ": "Current version: ",
"error_from_youtube": "YouTube returned an error:",
"next_steps_error_message": "After which you should try to: ",
"next_steps_error_message_refresh": "Refresh",
"next_steps_error_message_go_to_alltube": "Download the video using AllTube",

View file

@ -86,7 +86,10 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, mess
locale = env.get("preferences").as(Preferences).locale
error_message_description = translate(locale, "error_from_youtube")
error_message = translate(locale, message)
error_message = "#{error_message_description} #{error_message}"
next_steps = error_redirect_helper(env)
return templated "error"