All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hubspot.jinjava.interpret.FatalTemplateErrorsException Maven / Gradle / Ivy

There is a newer version: 2.7.3
Show newest version
package com.hubspot.jinjava.interpret;

import java.util.Collection;

/**
 * Container exception thrown when fatal errors are encountered while rendering a template.
 *
 * @author jstehler
 */
public class FatalTemplateErrorsException extends InterpretException {
  private static final long serialVersionUID = 1L;

  private final String template;
  private final Iterable errors;

  public FatalTemplateErrorsException(String template, Collection errors) {
    super(generateMessage(errors));
    this.template = template;
    this.errors = errors;
  }

  private static String generateMessage(Collection errors) {
    if (errors.isEmpty()) {
      throw new IllegalArgumentException("FatalTemplateErrorsException should have at least one error");
    }

    return errors.iterator().next().getMessage();
  }

  public String getTemplate() {
    return template;
  }

  public Iterable getErrors() {
    return errors;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy