Skip to content

Commit 7d11912

Browse files
committed
better error handling
1 parent 388a551 commit 7d11912

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lua/CopilotChat/client.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,13 @@ function Client:models()
252252

253253
local ok, headers = pcall(self.authenticate, self, provider_name)
254254
if not ok then
255-
log.warn('Failed to authenticate with ' .. provider_name .. ': ' .. headers)
255+
log.error('Failed to authenticate with ' .. provider_name .. ': ' .. headers)
256+
local user_err_msg = 'Failed to authenticate with ' .. provider_name
257+
-- append error details, if available
258+
if headers.error_details and headers.error_details.message then
259+
user_err_msg = user_err_msg .. ' the server replied : ' .. headers.error_details.message
260+
end
261+
error(user_err_msg)
256262
return {}
257263
end
258264

0 commit comments

Comments
 (0)