Templater icon indicating copy to clipboard operation
Templater copied to clipboard

Useful error stacktraces

Open elight opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe. debugging templates is painful due to stacktraces never indicating the file resulting in the error. Nested templates are particularly challenging to debug because of this.

Describe the solution you'd like Impl suggestion: add incremental execution of templates, to Templater such that Templater can at least indicate which template resulted in the error.

elight avatar Aug 14 '22 14:08 elight

Hello again! 'Tis a great idea but for now I wrap my stuff in a try catch and output the log to the note. Makes life easier on mobile. Of course, you probably do that already so cheers to any future requesters.

AB1908 avatar Aug 26 '22 22:08 AB1908

a) how do you do that @AB1908 and what is the difference to the normal log? b) a lot of the times troubleshooting is easy but there are several things which are problematic.

  • the ones where you get an error and get the whole tR part printed without indicating where the error is
  • something like this
 plugin:templater-obsidian:82 Templater Error: Template parsing error, aborting. 
 Cannot read properties of null (reading '1') 

with a template from https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/550 . I haven't really had the time to troubleshoot this

I know that a lot of the time the errors are thrown by libraries to parse content and it is then hard to figure out where it happened (staring at yaml parser in java, as an example). One workaround would be to create an own parser to look for certain typical issues and either fix them or throw a better error message in that case (wrote my own yaml fixer because of that).

so yeah... a tremendous task depending where the issues are hidden.

dredhorse avatar Sep 28 '22 19:09 dredhorse

another of those exceptions which could use a better message while renaming a file

plugin:templater-obsidian:82 Templater Error: Template parsing error, aborting. 
 Destination file already exists!

(as this is happening during mass creation of notes I don't even now which note is causing it.) If the file you want to rename doesn't exist anymore you get

Templater Error: Template parsing error, aborting. 
 ENOENT: no such file or directory, rename '/Best Train Lines for Living in Tokyo The Yamanote Line.md' -> '/SM - 5 Nature-Themed Activities to Try on Japans Amami Oshima Island.md'

which is a lot more helpful

dredhorse avatar Sep 29 '22 13:09 dredhorse