MCPcopy
hub / github.com/continuedev/continue / parseError

Function parseError

core/llm/index.ts:405–447  ·  view source on GitHub ↗
(resp: any)

Source from the content-addressed store, hash-verified

403 }
404
405 private async parseError(resp: any): Promise<Error> {
406 let text = await resp.text();
407
408 if (resp.status === 404 && !resp.url.includes("/v1")) {
409 const parsedError = JSON.parse(text);
410 const errorMessageRaw = parsedError?.error ?? parsedError?.message;
411 const error =
412 typeof errorMessageRaw === "string"
413 ? errorMessageRaw.replace(/"/g, "'")
414 : undefined;
415 let model = error?.match(/model '(.*)' not found/)?.[1];
416 if (model && resp.url.match("127.0.0.1:11434")) {
417 text = `The model "${model}" was not found. To download it, run \`ollama run ${model}\`.`;
418 return new LLMError(text, this); // No need to add HTTP status details
419 } else if (text.includes("/api/chat")) {
420 text =
421 "The /api/chat endpoint was not found. This may mean that you are using an older version of Ollama that does not support /api/chat. Upgrading to the latest version will solve the issue.";
422 } else {
423 text =
424 "This may mean that you forgot to add '/v1' to the end of your 'apiBase' in config.json.";
425 }
426 } else if (resp.status === 404 && resp.url.includes("api.openai.com")) {
427 text =
428 "You may need to add pre-paid credits before using the OpenAI API.";
429 } else if (
430 resp.status === 401 &&
431 (resp.url.includes("api.mistral.ai") ||
432 resp.url.includes("codestral.mistral.ai"))
433 ) {
434 if (resp.url.includes("codestral.mistral.ai")) {
435 return new Error(
436 "You are using a Mistral API key, which is not compatible with the Codestral API. Please either obtain a Codestral API key, or use the Mistral API by setting 'apiBase' to 'https://api.mistral.ai/v1' in config.json.",
437 );
438 } else {
439 return new Error(
440 "You are using a Codestral API key, which is not compatible with the Mistral API. Please either obtain a Mistral API key, or use the the Codestral API by setting 'apiBase' to 'https://codestral.mistral.ai/v1' in config.json.",
441 );
442 }
443 }
444 return new Error(
445 `HTTP ${resp.status} ${resp.statusText} from ${resp.url}\n\n${text}`,
446 );
447 }
448
449 fetch(url: RequestInfo | URL, init?: RequestInit): Promise<Response> {
450 // Custom Node.js fetch

Callers

nothing calls this directly

Calls 2

textMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected