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:
1 file changed
+7
-1
@@ -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}`);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user