Auto tagging obsidian notes w/ AI
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Surface API errors to users in notifications

Show meaningful error messages when tagging fails instead of silently logging to console.

+23 -6
+16 -3
src/main.ts
··· 186 186 ); 187 187 188 188 // Final notice with completion message 189 - notification.setSuccess( 190 - `Completed tagging ${result.successful}/${result.total} notes successfully` 191 - ); 189 + if (result.failed > 0 && result.successful === 0) { 190 + // All notes failed - show error with details 191 + notification.setError( 192 + `Failed to tag all ${result.total} notes.\n${result.lastError || "Unknown error"}` 193 + ); 194 + } else if (result.failed > 0) { 195 + // Some notes failed - show mixed result 196 + notification.setError( 197 + `Tagged ${result.successful}/${result.total} notes. ${result.failed} failed.\n${result.lastError || ""}` 198 + ); 199 + } else { 200 + // All notes succeeded 201 + notification.setSuccess( 202 + `Completed tagging ${result.successful}/${result.total} notes successfully` 203 + ); 204 + } 192 205 } catch (error) { 193 206 console.error("Error during bulk tagging:", error); 194 207 const errorMessage =
+7 -3
src/services/noteService.ts
··· 61 61 app: App, 62 62 settings: AITaggerSettings, 63 63 progressCallback?: (processed: number, successful: number, total: number, currentFile: string) => void 64 - ): Promise<{ successful: number, total: number }> { 64 + ): Promise<{ successful: number, total: number, failed: number, lastError?: string }> { 65 65 const files = app.vault.getMarkdownFiles(); 66 66 let processed = 0; 67 67 let successful = 0; 68 + let failed = 0; 69 + let lastError: string | undefined; 68 70 69 71 for (const file of files) { 70 72 try { ··· 72 74 if (progressCallback) { 73 75 progressCallback(processed, successful, files.length, file.path); 74 76 } 75 - 77 + 76 78 const content = await app.vault.read(file); 77 79 const tags = await generateTags(content, settings); 78 80 await updateNoteFrontmatter(app, file, tags); 79 81 successful++; 80 82 } catch (error) { 81 83 console.error(`Error tagging note ${file.path}:`, error); 84 + failed++; 85 + lastError = error instanceof Error ? error.message : String(error); 82 86 } 83 87 84 88 processed++; 85 89 } 86 90 87 - return { successful, total: files.length }; 91 + return { successful, total: files.length, failed, lastError }; 88 92 }