From 0f08cc5aa9c6fe2c9810872b375354a9d6549347 Mon Sep 17 00:00:00 2001 From: saltycrys <73420320+saltycrys@users.noreply.github.com> Date: Mon, 30 Nov 2020 12:57:25 +0100 Subject: [PATCH 1/2] Remove backtrace on YouTube error YouTube returning an error is not a bug in Invidious, so it should not print a backtrace. --- src/invidious/videos.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 200484606..8b20c181c 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -998,7 +998,7 @@ def fetch_video(id, region) }.try { |a| JSON::Any.new(a) } || JSON::Any.new([] of JSON::Any) end - raise info["reason"]?.try &.as_s || "" if !info["videoDetails"]? + raise InfoException.new(info["reason"]?.try &.as_s || "") if !info["videoDetails"]? video = Video.new({ id: id, From 92bb477f68d6efe8966b692e93df9fca55ec31ec Mon Sep 17 00:00:00 2001 From: saltycrys <73420320+saltycrys@users.noreply.github.com> Date: Mon, 30 Nov 2020 13:02:35 +0100 Subject: [PATCH 2/2] Improve error message The error message has been reworded and the issue template now includes the date, route, version and backtrace. --- src/invidious/helpers/errors.cr | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/invidious/helpers/errors.cr b/src/invidious/helpers/errors.cr index 927a398ff..c9f3c06c0 100644 --- a/src/invidious/helpers/errors.cr +++ b/src/invidious/helpers/errors.cr @@ -15,16 +15,16 @@ def error_template_helper(env : HTTP::Server::Context, config : Config, locale : return error_template_helper(env, config, locale, status_code, exception.message || "") end env.response.status_code = status_code + issue_template = %(Date: `#{Time::Format::ISO_8601_DATE_TIME.format(Time.utc)}`) + issue_template += %(\nRoute: `#{env.request.resource}`) + issue_template += %(\nVersion: `#{SOFTWARE["version"]} @ #{SOFTWARE["branch"]}`) + #issue_template += %(\nPreferences: ```#{env.get("preferences").as(Preferences).to_json}```) + issue_template += %(\nBacktrace: \n```\n#{exception.inspect_with_backtrace}```) error_message = <<-END_HTML - Looks like you've found a bug in Invidious. Feel free to open a new issue - here - or send an email to - #{CONFIG.admin_email}. -
-
-
- Please include the following text in your message: -
#{exception.inspect_with_backtrace}
+ Looks like you've found a bug in Invidious. Please open a new issue + on GitHub + and include the following text in your message: +
#{issue_template}
END_HTML return templated "error" end