feat(scraper): add on_error callback to scrape_contest_metadata

Problem: `scrape_contest_metadata` silently swallowed failures — the
callback simply never fired, giving callers no way to detect or react
to scraper errors.

Solution: Add optional `on_error` parameter invoked on scraper failure
or empty problems result. Backward-compatible — existing callers are
unchanged.
This commit is contained in:
Barrett Ruth 2026-03-06 18:41:54 -05:00
parent bd0ae25d4b
commit faa79c88c7
Signed by: barrett
GPG key ID: A6C96C9349D2FC81

View file

@ -216,7 +216,7 @@ local function run_scraper(platform, subcommand, args, opts)
end
end
function M.scrape_contest_metadata(platform, contest_id, callback)
function M.scrape_contest_metadata(platform, contest_id, callback, on_error)
run_scraper(platform, 'metadata', { contest_id }, {
on_exit = function(result)
if not result or not result.success then
@ -227,6 +227,9 @@ function M.scrape_contest_metadata(platform, contest_id, callback)
),
{ level = vim.log.levels.ERROR }
)
if type(on_error) == 'function' then
on_error()
end
return
end
local data = result.data or {}
@ -238,6 +241,9 @@ function M.scrape_contest_metadata(platform, contest_id, callback)
),
{ level = vim.log.levels.ERROR }
)
if type(on_error) == 'function' then
on_error()
end
return
end
if type(callback) == 'function' then