Repository navigation
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #420
When the template file path in the settings is wrong,
app.vault.adapter.read(templatePath)throws insidenewNote()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
returninstead; I can change it.Verification
npx prettier --check src/utils.ts: passednpx tsc --noEmit: 5 errors, none insrc/utils.ts(basesMapView.ts,tests/__mocks__/*,vitest.config.ts). The same 5 errors appear without my changenpm test: 382 tests passedI 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.