From a2600acfa9327ae7d1c01af2ccd5595f0617f5e0 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Tue, 2 Nov 2021 15:43:26 +0100 Subject: Improve crash page messages * Ask to read the FAQ and search for existing issues on Github * Include links to FAQ and directly to a new github issue * Github issue title is automatically based on exception name * Improved HTML * Minor languages changes --- src/invidious/helpers/errors.cr | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/invidious/helpers/errors.cr b/src/invidious/helpers/errors.cr index d10762c5..dbcc6068 100644 --- a/src/invidious/helpers/errors.cr +++ b/src/invidious/helpers/errors.cr @@ -26,19 +26,44 @@ def error_template_helper(env : HTTP::Server::Context, locale : String?, status_ if exception.is_a?(InfoException) return error_template_helper(env, locale, status_code, exception.message || "") end + env.response.content_type = "text/html" env.response.status_code = status_code - issue_template = %(Title: `#{exception.message} (#{exception.class})`) + + issue_title = "#{exception.message} (#{exception.class})" + + issue_template = %(Title: `#{issue_title}`) issue_template += %(\nDate: `#{Time::Format::ISO_8601_DATE_TIME.format(Time.utc)}`) issue_template += %(\nRoute: `#{env.request.resource}`) issue_template += %(\nVersion: `#{SOFTWARE["version"]} @ #{SOFTWARE["branch"]}`) # issue_template += github_details("Preferences", env.get("preferences").as(Preferences).to_pretty_json) issue_template += github_details("Backtrace", exception.inspect_with_backtrace) + + # URLs for the error message below + url_faq = "https://github.com/iv-org/documentation/blob/master/FAQ.md" + url_search_issues = "https://github.com/iv-org/invidious/issues" + + url_new_issue = "https://github.com/iv-org/invidious/issues/new" + url_new_issue += "?labels=bug&template=bug_report.md&title=" + url_new_issue += URI.encode_www_form("[Bug] " + issue_title) + error_message = <<-END_HTML - 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}
+
+

#{translate(locale, "crash_page_you_found_a_bug")}

+

+ +

#{translate(locale, "crash_page_before_reporting")}

+ + +
+

#{translate(locale, "crash_page_report_issue", url_new_issue)}

+ + +
#{issue_template}
+
END_HTML next_steps = error_redirect_helper(env, locale) -- cgit v1.2.3