Update coverage reports and improve error handling

This commit is contained in:
2026-05-06 19:28:40 +02:00
parent 2968932d69
commit d57ade0ba8
22 changed files with 1851 additions and 1707 deletions
+6 -15
View File
@@ -1,14 +1,9 @@
import { Plugin, WorkspaceLeaf, App, Setting, Notice, PluginSettingTab } from 'obsidian';
import { ChatView } from './chat-view';
import { PluginSettings } from './types';
import {
isValidHttpUrl,
validatePluginSettings,
validateOllamaUrl,
validateModelName,
Logger,
} from './utils';
import { validatePluginSettings, validateOllamaUrl, validateModelName, Logger } from './utils';
import { DEFAULT_SETTINGS } from './constants';
import { ErrorHandler } from './error-handler';
export default class OllamaPlugin extends Plugin {
settings: PluginSettings = DEFAULT_SETTINGS;
@@ -38,7 +33,7 @@ export default class OllamaPlugin extends Plugin {
type: 'ollama-chat-view',
active: true,
});
this.app.workspace.revealLeaf(leaf);
await this.app.workspace.revealLeaf(leaf);
});
} catch (error) {
Logger.error('Failed to add ribbon icon: ' + (error as Error).message, 'plugin');
@@ -51,14 +46,12 @@ export default class OllamaPlugin extends Plugin {
async loadSettings() {
try {
const data = await this.loadData();
const data = (await this.loadData()) as Partial<PluginSettings> | null;
if (data) {
Logger.debug('Loading saved settings', 'settings');
this.settings = Object.assign({}, this.settings, data);
}
} catch (error) {
// Use centralized error handling
const { ErrorHandler } = await import('./error-handler');
ErrorHandler.handleError(error, 'settings load');
}
}
@@ -81,8 +74,6 @@ export default class OllamaPlugin extends Plugin {
Logger.info('Settings saved successfully', 'settings');
return true;
} catch (error) {
// Use centralized error handling
const { ErrorHandler } = await import('./error-handler');
ErrorHandler.handleError(error, 'settings save');
return false;
}
@@ -92,8 +83,8 @@ export default class OllamaPlugin extends Plugin {
public notifyChatViews(): void {
const leaves = this.app.workspace.getLeavesOfType('ollama-chat-view');
leaves.forEach((leaf) => {
const view = leaf.view as ChatView;
if (view && view.onSettingsChange) {
const view = leaf.view;
if (view instanceof ChatView) {
view.onSettingsChange(this.settings);
}
});