feat(provider): initial error handling on claude (#221)

* fix: improve error handling for common issues

* fix: Providers.on_error for handling API errors

* Update lua/avante/providers/init.lua

---------

Co-authored-by: Aaron Pham <Aaronpham0103@gmail.com>
This commit is contained in:
Jake
2024-08-25 21:26:19 -04:00
committed by GitHub
parent 5159aeefd1
commit 312543b680
3 changed files with 31 additions and 1 deletions

View File

@@ -148,7 +148,14 @@ M.stream = function(question, code_lang, code_content, selected_content_content,
on_error = function(err)
on_complete(err)
end,
callback = function(_)
callback = function(result)
if result.status >= 400 then
if Provider.on_error then
Provider.on_error(result)
else
Utils.error("API request failed with status " .. result.status, { once = true, title = "Avante" })
end
end
active_job = nil
end,
})