feat: improve UX for Ollama 404 errors (missing model)
- src/ollama-client.ts: Detect HTTP 404 on /api/chat and throw a descriptive ApiError with the model name and the exact ollama pull command needed. - src/error-handler.ts: For API_ERROR type, return the error message directly instead of prefixing with 'API error: ', so the user-friendly 404 message is shown cleanly in the Obsidian notice. - tests/ollama-client.test.ts: Update 404 assertions to match the new descriptive error message.
This commit is contained in:
@@ -214,7 +214,7 @@ describe('OllamaClient', () => {
|
||||
mockFetch.mockResolvedValue({ ok: false, status: 404 });
|
||||
|
||||
await expect(client.streamChatAsPromise(mockMessages, mockTools)).rejects.toThrow(
|
||||
'Ollama API error: 404'
|
||||
'Model "llama3" not found. Run \`ollama pull llama3\` first.'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -418,7 +418,7 @@ describe('OllamaClient', () => {
|
||||
/* consume */
|
||||
}
|
||||
})()
|
||||
).rejects.toThrow('Ollama API error: 404');
|
||||
).rejects.toThrow('Model "llama3" not found. Run \`ollama pull llama3\` first.');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user