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:
parent
bd0ae25d4b
commit
faa79c88c7
1 changed files with 7 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue