Skip to content

Commit d4f3139

Browse files
Don't catch and provide better error message instead
1 parent 97dceb3 commit d4f3139

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/invidious/search.cr

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
class ChannelSearchException < InfoException
2+
def initialize(channel : String)
3+
super "Unable to find channel with id of '#{channel}'. Are you sure that's an actual channel id?"
4+
end
25
end
36

47
def channel_search(query, page, channel)
@@ -9,7 +12,7 @@ def channel_search(query, page, channel)
912
response = YT_POOL.client &.get("/c/#{channel}") if response.status_code == 404
1013
initial_data = extract_initial_data(response.body)
1114
ucid = initial_data.dig?("header", "c4TabbedHeaderRenderer", "channelId").try(&.as_s?)
12-
raise ChannelSearchException.new("Impossible to extract channel ID from page") if !ucid
15+
raise ChannelSearchException.new(channel) if !ucid
1316
else
1417
ucid = channel
1518
end
@@ -213,13 +216,7 @@ def process_search_query(query, page, user, region)
213216
search_query = (query.split(" ") - operators).join(" ")
214217

215218
if channel
216-
begin
217-
count, items = channel_search(search_query, page, channel)
218-
rescue ChannelSearchException
219-
# most likely reason for this is that they provided an invalid channel id to the search
220-
count = 0
221-
items = [] of ChannelVideo
222-
end
219+
count, items = channel_search(search_query, page, channel)
223220
elsif subscriptions
224221
if view_name
225222
items = PG_DB.query_all("SELECT id,title,published,updated,ucid,author,length_seconds FROM (

0 commit comments

Comments
 (0)