templateEngineExceptionsFromException function

Iterable<TemplateEngineException> templateEngineExceptionsFromException(
  1. dynamic exception
)

Converts a thrown value into the template-engine errors it contains.

Existing TemplateEngineExceptions and nested iterables of such errors are returned; unrelated values produce an empty iterable.

Implementation

Iterable<TemplateEngineException> templateEngineExceptionsFromException(
  dynamic exception,
) {
  if (exception is TemplateEngineException) {
    return [exception];
  } else if (exception is Iterable) {
    return exception.expand(templateEngineExceptionsFromException);
  } else {
    return [];
  }
}