* Type-safe file opening with proper error handling
(filePath: string)
| 299 | * Type-safe file opening with proper error handling |
| 300 | */ |
| 301 | private async safeOpenFile(filePath: string): Promise<void> { |
| 302 | try { |
| 303 | const file = this.app.vault.getAbstractFileByPath(filePath); |
| 304 | if (file instanceof TFile) { |
| 305 | await this.app.workspace.getLeaf().openFile(file); |
| 306 | } else { |
| 307 | new Notice(this.translate("notices.icsFileNotFound")); |
| 308 | tasknotesLogger.error("Invalid file path or file not found:", { |
| 309 | category: "provider", |
| 310 | operation: "invalid-file-path-or-file-not-found", |
| 311 | details: { value: filePath }, |
| 312 | }); |
| 313 | } |
| 314 | } catch (error) { |
| 315 | tasknotesLogger.error("Error opening file:", { |
| 316 | category: "provider", |
| 317 | operation: "opening-file", |
| 318 | error: error, |
| 319 | }); |
| 320 | new Notice(this.translate("notices.icsFileOpenFailed")); |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | onClose() { |
| 325 | const { contentEl } = this; |
no test coverage detected