///|
/// A structural error discovered before or during named-template rendering.
pub(all) enum RenderError {
  TemplateNotFound(String)
  ParentNotFound(String)
  InheritanceCycle(String)
  IncludeNotFound(String)
  IncludeCycle(String)
} derive(Debug, Eq)

///|
/// Return a stable diagnostic message suitable for CLIs and logs.
pub fn RenderError::message(self : RenderError) -> String {
  match self {
    TemplateNotFound(name) => "template not found: " + name
    ParentNotFound(name) => "parent template not found: " + name
    InheritanceCycle(name) => "template inheritance cycle detected at: " + name
    IncludeNotFound(name) => "included template not found: " + name
    IncludeCycle(name) => "template include cycle detected at: " + name
  }
}