diff options
| author | syeopite <syeopite@syeopite.dev> | 2025-02-28 20:42:07 -0800 |
|---|---|---|
| committer | syeopite <syeopite@syeopite.dev> | 2025-03-19 22:52:03 -0700 |
| commit | 9de69c0052b004c22a1d83f10193e13d1f3d5c58 (patch) | |
| tree | dad59bab89f44e250c8b1d92bf8745688915b06b /src | |
| parent | dbeee714577846e496eedbf4fb18cf20c66115ea (diff) | |
| download | invidious-9de69c0052b004c22a1d83f10193e13d1f3d5c58.tar.gz invidious-9de69c0052b004c22a1d83f10193e13d1f3d5c58.tar.bz2 invidious-9de69c0052b004c22a1d83f10193e13d1f3d5c58.zip | |
Improve design of placeholder item
Also makes it show the error backtrace
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/helpers/errors.cr | 29 | ||||
| -rw-r--r-- | src/invidious/views/components/item.ecr | 12 |
2 files changed, 29 insertions, 12 deletions
diff --git a/src/invidious/helpers/errors.cr b/src/invidious/helpers/errors.cr index 900cb0c6..399324cd 100644 --- a/src/invidious/helpers/errors.cr +++ b/src/invidious/helpers/errors.cr @@ -18,16 +18,7 @@ def github_details(summary : String, content : String) return HTML.escape(details) end -def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exception : Exception) - if exception.is_a?(InfoException) - return error_template_helper(env, status_code, exception.message || "") - end - - locale = env.get("preferences").as(Preferences).locale - - env.response.content_type = "text/html" - env.response.status_code = status_code - +def get_issue_template(env : HTTP::Server::Context, exception : Exception) : Tuple(String, String) issue_title = "#{exception.message} (#{exception.class})" issue_template = <<-TEXT @@ -40,6 +31,24 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exce issue_template += github_details("Backtrace", exception.inspect_with_backtrace) + return {issue_title, issue_template} +end + +def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exception : Exception) + if exception.is_a?(InfoException) + return error_template_helper(env, status_code, exception.message || "") + end + + locale = env.get("preferences").as(Preferences).locale + + env.response.content_type = "text/html" + env.response.status_code = status_code + + # Unpacking into issue_title, issue_template directly causes a compiler error + # I have no idea why. + issue_template_components = get_issue_template(env, exception) + issue_title, issue_template = issue_template_components + # 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" diff --git a/src/invidious/views/components/item.ecr b/src/invidious/views/components/item.ecr index 79cc4725..348ea127 100644 --- a/src/invidious/views/components/item.ecr +++ b/src/invidious/views/components/item.ecr @@ -98,8 +98,16 @@ </div> <% when Category %> <% when ProblematicTimelineItem %> - <div> - <h4> Unable to parse this item </h4> + <div class="error-card"> + <div class="explanation"> + <i class="icon ion-ios-alert"></i> + <h4><%=translate(locale, "timeline_parse_error_placeholder_heading")%></h4> + <p><%=translate(locale, "timeline_parse_error_placeholder_message")%></p> + </div> + <details> + <summary class="pure-button pure-button-secondary"> Show technical details </summary> + <pre style="padding: 20px; background: rgba(0, 0, 0, 0.12345);"><%=get_issue_template(env, item.parse_exception)[1]%></pre> + </details> </div> <% else %> <%- |
