From 8dc6f03ece4f3f34e1678acd426fb39edfdb681d Mon Sep 17 00:00:00 2001 From: Kumi Date: Sat, 19 Oct 2024 11:27:33 +0200 Subject: [PATCH] fix: improve error messaging for YouTube API errors 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. --- locales/en-US.json | 1 + src/invidious/helpers/errors.cr | 3 +++ 2 files changed, 4 insertions(+) diff --git a/locales/en-US.json b/locales/en-US.json index 30c12f85..9dc54c2c 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -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", diff --git a/src/invidious/helpers/errors.cr b/src/invidious/helpers/errors.cr index 3a1beb0e..d74a8b53 100644 --- a/src/invidious/helpers/errors.cr +++ b/src/invidious/helpers/errors.cr @@ -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"