diff --git a/src/invidious/helpers/errors.cr b/src/invidious/helpers/errors.cr index 11c7a598..8b8720aa 100644 --- a/src/invidious/helpers/errors.cr +++ b/src/invidious/helpers/errors.cr @@ -28,48 +28,7 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exce env.response.content_type = "text/html" env.response.status_code = status_code - issue_title = "#{exception.message} (#{exception.class})" - - issue_template = <<-TEXT - Title: `#{HTML.escape(issue_title)}` - Date: `#{Time::Format::ISO_8601_DATE_TIME.format(Time.utc)}` - Route: `#{HTML.escape(env.request.resource)}` - Version: `#{SOFTWARE["version"]} @ #{SOFTWARE["branch"]}` - - TEXT - - 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/docs/faq.md" - url_search_issues = "https://github.com/iv-org/invidious/issues" - - url_switch = "https://redirect.invidious.io" + env.request.resource - - 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 -
-

#{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 + error_message = error_template_message(env, exception) # Don't show the usual "next steps" widget. The same options are # proposed above the error message, just worded differently. @@ -90,13 +49,8 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, mess return templated "error" end -# ------------------- -# Mini error templates (for components that had an error) -# ------------------- - -def mini_error_template(env : HTTP::Server::Context, exception : Exception) +def error_template_message(env : HTTP::Server::Context, exception : Exception) String.build do |str| - # Copied from error_template_helper locale = env.get("preferences").as(Preferences).locale issue_title = "#{exception.message} (#{exception.class})" diff --git a/src/invidious/routes/api/v1/videos.cr b/src/invidious/routes/api/v1/videos.cr index 1bd07ccf..bc1da917 100644 --- a/src/invidious/routes/api/v1/videos.cr +++ b/src/invidious/routes/api/v1/videos.cr @@ -337,7 +337,7 @@ module Invidious::Routes::API::V1::Videos rescue ex : NotFoundException return error_json(404, ex) rescue ex - return error_json(500, ex, {"errorHtml" => mini_error_template(env, ex)}) + return error_json(500, ex, {"errorHtml" => error_template_message(env, ex)}) end return comments diff --git a/src/invidious/routes/watch.cr b/src/invidious/routes/watch.cr index 7862b061..47fba2a0 100644 --- a/src/invidious/routes/watch.cr +++ b/src/invidious/routes/watch.cr @@ -104,7 +104,7 @@ module Invidious::Routes::Watch comment_html = Comments.fill_links(comment_html, "https", "www.reddit.com") comment_html = Comments.replace_links(comment_html) else - comment_html = mini_error_template(env, ex) + comment_html = error_template_message(env, ex) end end elsif source == "reddit" @@ -118,7 +118,7 @@ module Invidious::Routes::Watch if preferences.comments[1] == "youtube" comment_html = JSON.parse(Comments.fetch_youtube(id, nil, "html", locale, preferences.thin_mode, region))["contentHtml"] else - comment_html = mini_error_template(env, ex) + comment_html = error_template_message(env, ex) end end end