Skip to content

fix: show notice when template file path is incorrect - #424

Open
dbdefault wants to merge 1 commit into
esm7:masterfrom
dbdefault:fix/template-path-warning
Open

dbdefault wants to merge 1 commit into
esm7:masterfrom
dbdefault:fix/template-path-warning

Conversation

@dbdefault

@dbdefault dbdefault commented Nov 10, 2026 •

Copy link
Copy Markdown

Closes #420

When the template file path in the settings is wrong, app.vault.adapter.read(templatePath) throws inside newNote() and the note is silently not created. The only trace is an error in the developer console, as described in the issue.

This wraps that read in a try/catch and shows new Notice("Template file not found: <path>"). Note creation then continues without template content.

That last part is a design choice I made and the issue does not state it: the issue asks for the error to be shown, not for the note to be created or not. If you would rather abort and create no note when the template is missing, the catch block can return instead; I can change it.

Verification

  • npx prettier --check src/utils.ts: passed
  • npx tsc --noEmit: 5 errors, none in src/utils.ts (basesMapView.ts, tests/__mocks__/*, vitest.config.ts). The same 5 errors appear without my change
  • npm test: 382 tests passed

I did not add a test for the new Notice path; the existing tests do not cover newNote().

AI assistance

This fix was developed with AI assistance.

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 esm7#420

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No warning/error when template file path is incorrect

1 participant