java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
io.github.chkrishnatej.rp3200.template.TemplateException
All Implemented Interfaces:
Serializable

public class TemplateException extends RuntimeException
Thrown when a receipt template cannot be compiled or rendered.

The message always says what is wrong and where, for example:

  • Line 3: '{{#each items}}' is never closed - thrown by ReceiptTemplate.compile(String): the placeholder structure is broken.
  • Output line 5 "[blink]x": Unknown tag [blink] ... - thrown while rendering: the markup is wrong. "Output line" counts lines after placeholders were filled in; ReceiptTemplate.expand(Object) shows that intermediate text.

It is unchecked: a broken template is a programming error, best caught by a unit test that renders every template once (see ReceiptTemplate.preview(Object)).

See Also:
  • Constructor Details

    • TemplateException

      public TemplateException(String message)
      Creates an exception with a message.
      Parameters:
      message - what is wrong and where
    • TemplateException

      public TemplateException(String message, Throwable cause)
      Creates an exception with a message and the underlying cause.
      Parameters:
      message - what is wrong and where
      cause - the original exception