Handle parse errors gracefully on timeline items

Prior to this commit, if even a single item fails to parse Invidious
will throw out an error. This means that even if everything else
on a page can be parsed and rendered without issues, the single
problematic item will cause the entire page to be unusable.

This commit gracefully handles parse errors by catching and then
replacing the problematic item with a new "timeline error" object
that represents the parse error. This will allow the rest of the page
to be rendered and an error card that will replace the location of the
problematic item.
This commit is contained in:
syeopite
2025-02-28 18:21:35 -08:00
parent 409d12a81e
commit 94cb80ea81
3 changed files with 82 additions and 17 deletions

View File

@@ -1,6 +1,6 @@
<%-
thin_mode = env.get("preferences").as(Preferences).thin_mode
item_watched = !item.is_a?(SearchChannel | SearchHashtag | SearchPlaylist | InvidiousPlaylist | Category) && env.get?("user").try &.as(User).watched.index(item.id) != nil
item_watched = !item.is_a?(SearchChannel | SearchHashtag | SearchPlaylist | InvidiousPlaylist | Category | ProblematicTimelineItem) && env.get?("user").try &.as(User).watched.index(item.id) != nil
author_verified = item.responds_to?(:author_verified) && item.author_verified
-%>
@@ -97,6 +97,10 @@
</div>
</div>
<% when Category %>
<% when ProblematicTimelineItem %>
<div>
<h4> Unable to parse this item </h4>
</div>
<% else %>
<%-
# `endpoint_params` is used for the "video-context-buttons" component