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.
This commit is contained in:
AlexKucera committed 2025-11-08 18:39:50 +01:00
1 parent 003d6d105b
commit 1ac2807320
1 file changed
+7 -1
+7 -1
View File
@@ -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}`);
});
}
});