Aldaviva / WinampNowPlayingToFile

⚡ When Winamp plays a track, this plugin will save the track metadata and album art to files.
Apache License 2.0
17 stars 1 forks source link

Uncaught exception while manually typing placeholder names #3

Closed Aldaviva closed 2 years ago

Aldaviva commented 2 years ago

Steps

  1. Use the insertion menu to insert the If pattern into the template text.
  2. Replace the Artist variable with a different variable, like Year. Do this by manually typing Year one character at a time.

    Expected

    The live preview should just use some dummy value such as Y or null when rendering that placeholder, or maybe replace the rendered text with a helpful message like invalid template. This can apply to both the preview as well as the contents of the text file.

    Actual

    A KeyNotFoundException is actually thrown:

    System.Collections.Generic.KeyNotFoundException: The key Y could not be found.
    at Mustache.Scope.Find(String name, Boolean isExtension)
    at Mustache.PlaceholderArgument.GetValue(Scope keyScope, Scope contextScope)
    at Mustache.ArgumentCollection.GetArguments(Scope keyScope, Scope contextScope)
    at Mustache.CompoundGenerator.Mustache.IGenerator.GetText(TextWriter writer, Scope keyScope, Scope contextScope, Action`1 postProcessor)
    at Mustache.CompoundGenerator.Mustache.IGenerator.GetText(TextWriter writer, Scope keyScope, Scope contextScope, Action`1 postProcessor)
    at Mustache.Generator.render(IFormatProvider provider, Object source)
    at WinampNowPlayingToFile.Presentation.SettingsDialog.renderPreview()
    at WinampNowPlayingToFile.Presentation.SettingsDialog.TemplateEditor_TextChanged(Object sender, EventArgs e)
    at System.Windows.Forms.Control.OnTextChanged(EventArgs e)
    at System.Windows.Forms.TextBoxBase.OnTextChanged(EventArgs e)
    at System.Windows.Forms.TextBoxBase.WmReflectCommand(Message& m)
    at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
    at System.Windows.Forms.TextBox.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Aldaviva commented 2 years ago

Now if your template text is {{Yea}}, the rendered text preview will be Template key not found: The key Yea could not be found., and the settings dialog box will refuse to save.