Skip to content

Commit

Permalink
fix: Handle error responses from copilot properly (#272)
Browse files Browse the repository at this point in the history
Copilot api can return error off-topic for example, when you try something
like this:

`Why weren't I invited when my parents got married?`

Signed-off-by: Tomas Slusny <[email protected]>
  • Loading branch information
deathbeam authored Apr 12, 2024
1 parent 5140ae9 commit 7388fe4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lua/CopilotChat/copilot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ function Copilot:ask(prompt, opts)
return
end

if err then
err = 'Failed to get response: ' .. vim.inspect(err)
if err or vim.startswith(line, '{"error"') then
err = 'Failed to get response: ' .. (err and vim.inspect(err) or line)
errored = true
log.error(err)
if self.current_job and on_error then
Expand Down

0 comments on commit 7388fe4

Please sign in to comment.