Skip to content

Commit 20f682d

Browse files
committed
improve error handling
1 parent 43d005a commit 20f682d

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

lua/CopilotChat/config/providers.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,18 @@ M.copilot = {
240240
error(err)
241241
end
242242

243-
if response.body.endpoints and response.body.endpoints.api then
243+
if response.body and response.body.endpoints and response.body.endpoints.api then
244244
log.info('get_headers ok, authenticated. Use api endpoint: ' .. response.body.endpoints.api)
245245
M.endpoints_api = response.body.endpoints.api
246246
else
247-
error('get_headers authenticated, but missing key "endpoints.api". response: ' .. utils.serializeTable(response))
247+
log.error(
248+
'get_headers authenticated, but missing key "endpoints.api" in server response. response: '
249+
.. utils.serializeTable(response)
250+
)
251+
error(
252+
'get_headers authenticated, but missing key "endpoints.api" in server response. Check log for details: '
253+
.. MC.config.log_path
254+
)
248255
end
249256

250257
return {

0 commit comments

Comments
 (0)