Skip to content

Commit 6aa43e0

Browse files
committed
consider authentication failure as critical error, report with appropriate message to user in chat pane
1 parent 14a2ab3 commit 6aa43e0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lua/CopilotChat/client.lua

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,19 +250,21 @@ function Client:models()
250250
ipairs(get_cached(self.provider_cache[provider_name], 'models', function()
251251
notify.publish(notify.STATUS, 'Fetching models from ' .. provider_name)
252252

253-
local ok, headers = pcall(self.authenticate, self, provider_name)
253+
local ok, headers_or_err = 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_or_err)
256+
error(headers_or_err)
256257
return {}
257258
end
258259

259-
local ok, models = pcall(provider.get_models, headers)
260+
local ok, models_or_err = pcall(provider.get_models, headers_or_err)
260261
if not ok then
261-
log.warn('Failed to fetch models from ' .. provider_name .. ': ' .. models)
262+
log.error('Failed to fetch models from ' .. provider_name .. ': ' .. models_or_err)
263+
error(models_or_err)
262264
return {}
263265
end
264266

265-
return models or {}
267+
return models_or_err or {}
266268
end))
267269
do
268270
model.provider = provider_name

0 commit comments

Comments
 (0)