From 1ac28073209e0caa121f9600abb4c8d944ed320d Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Sat, 8 Nov 2025 18:39:50 +0100 Subject: [PATCH] Enhances error handling with user notifications Adds user notifications for export and dependency status errors to improve feedback when operations fail. Utilizes Obsidian's Notice to display error messages to users. Relates to obsidian-bot-review branch improvements. --- src/plugin/CommandRegistry.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugin/CommandRegistry.ts b/src/plugin/CommandRegistry.ts index 714b3cf..be100b3 100644 --- a/src/plugin/CommandRegistry.ts +++ b/src/plugin/CommandRegistry.ts @@ -3,7 +3,7 @@ * Handles registration of all plugin commands and their callbacks */ -import { Editor, MarkdownView } from 'obsidian'; +import { Editor, MarkdownView, Notice } from 'obsidian'; import type { obsidianTypstPDFExport } from '../../main'; export class CommandRegistry { @@ -20,6 +20,8 @@ export class CommandRegistry { editorCallback: (editor: Editor, view: MarkdownView) => { this.plugin.exportCurrentNote(view).catch(error => { console.error('Failed to export current note:', error); + const errorMessage = error?.message ?? String(error); + new Notice(`Failed to export current note: ${errorMessage}`); }); } }); @@ -31,6 +33,8 @@ export class CommandRegistry { editorCallback: (editor: Editor, view: MarkdownView) => { this.plugin.showExportModal(view).catch(error => { console.error('Failed to show export modal:', error); + const errorMessage = error?.message ?? String(error); + new Notice(`Failed to show export modal: ${errorMessage}`); }); } }); @@ -42,6 +46,8 @@ export class CommandRegistry { callback: () => { this.plugin.showDependencyStatus().catch(error => { console.error('Failed to show dependency status:', error); + const errorMessage = error?.message ?? String(error); + new Notice(`Failed to show dependency status: ${errorMessage}`); }); } });