MCPcopy
hub / github.com/callumalpass/tasknotes / safeOpenFile

Method safeOpenFile

src/modals/ICSEventInfoModal.ts:301–322  ·  view source on GitHub ↗

* Type-safe file opening with proper error handling

(filePath: string)

Source from the content-addressed store, hash-verified

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;

Callers 3

renderContentMethod · 0.95
openCreationModalMethod · 0.95
createTaskDirectlyMethod · 0.95

Calls 4

getAbstractFileByPathMethod · 0.80
getLeafMethod · 0.80
errorMethod · 0.80
translateMethod · 0.65

Tested by

no test coverage detected