From 49056b3e09e51660007a4af4f93101afb4a6098e Mon Sep 17 00:00:00 2001 From: dbdefault Date: Tue, 10 Nov 2026 23:58:08 +0800 Subject: [PATCH] fix: show notice when template file path is incorrect Wrap app.vault.adapter.read(templatePath) in try/catch so that an invalid template file path shows a visible Notice instead of silently failing (error only visible in developer console). Note creation continues without template content when the path is wrong. Closes #420 --- src/utils.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 33c763b..5185f3a 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -137,8 +137,13 @@ export async function newNote( extraLocationData?: ExtraLocationData, ): Promise<[TFile, number]> { let templateContent = ''; - if (templatePath && templatePath.length > 0) - templateContent = await app.vault.adapter.read(templatePath); + if (templatePath && templatePath.length > 0) { + try { + templateContent = await app.vault.adapter.read(templatePath); + } catch (e) { + new Notice(`Template file not found: ${templatePath}`); + } + } templateContent = formatWithTemplates( templateContent,