mirror of
https://github.com/fbarrca/obsidian-inlineAI.git
synced 2026-07-22 11:50:24 +00:00
Added Notices for error handling with api endpoints
This commit is contained in:
parent
46e7d3c748
commit
9fe45103b9
1 changed files with 5 additions and 2 deletions
|
|
@ -55,7 +55,7 @@ export class ChatApiManager {
|
|||
}
|
||||
} catch (error) {
|
||||
console.error("Error initializing chat client:", error);
|
||||
new Notice(`Failed to initialize chat client. ${error}`);
|
||||
new Notice(`Error initializing chat client: ${error}`);
|
||||
throw new Error("Failed to initialize chat client.");
|
||||
}
|
||||
}
|
||||
|
|
@ -78,6 +78,7 @@ export class ChatApiManager {
|
|||
return aiMessage.content.toString();
|
||||
} catch (error) {
|
||||
console.error("Error calling the chat model:", error);
|
||||
new Notice(`Error calling the chat model: ${error}`);
|
||||
throw new Error("Failed to generate response from the chat model.");
|
||||
}
|
||||
}
|
||||
|
|
@ -91,6 +92,7 @@ export class ChatApiManager {
|
|||
private async handleEditorUpdate(systemPrompt: string, userRequest: string): Promise<string> {
|
||||
try {
|
||||
const response = await this.callApi(systemPrompt, userRequest);
|
||||
|
||||
const markdownView = this.app.workspace.getActiveViewOfType(MarkdownView);
|
||||
|
||||
if (!markdownView) return "";
|
||||
|
|
@ -103,6 +105,7 @@ export class ChatApiManager {
|
|||
return response;
|
||||
} catch (error) {
|
||||
console.error("Error processing request:", error);
|
||||
new Notice(`Error processing request: ${error}`);
|
||||
throw new Error("Failed to process request.");
|
||||
}
|
||||
}
|
||||
|
|
@ -129,7 +132,7 @@ export class ChatApiManager {
|
|||
|
||||
|
||||
const systemPrompt = isCursor ? this.settings.cursorPrompt : this.settings.selectionPrompt;
|
||||
let userPrompt = ``
|
||||
let userPrompt = ``;
|
||||
if (isCursor) {
|
||||
userPrompt = `
|
||||
**Task:** ${prompt}
|
||||
|
|
|
|||
Loading…
Reference in a new issue