template error handling

Template errors may occur in one of two contexts —
during loading or during evaluation.
It is of course possible that a loading error of one template
occurs during the evaluation of another, for example when a template
evoques another template that is not yet loaded.
Thus the big differentiator for errors is not the type of error
but when an error happens.

All errors not occurring during evaluation are raised as exceptions,
as any other normal application error.

The behaviour of evaluation errors may be controlled
via two domain parameters:

  • errors: int = 3

    sets evaluation behaviour for errors, and may be an int between 0 and 4:

    • 4 = raise
      will re-raise the exception given by the error.
    • 3 = render
      will render the error as a 1-line descriptive summary of the error.
    • 2 = name
      will render the error as the indicative string:
      EvalError[expr], where
      expr is the actual source of the
      failed expression.
    • 1 = zero
      (not yet implemented)
      assume the zero object for the inferred python type
      for the failed expression being evaluated. Examples,
      if a str then proceed with the empty string,
      if a list proceed with empty list,
      if an int proceed with 0, etc.
    • 0 = silent
      no output is generated for the error,
      i.e. errors are rendered as the the empty string.
  • log: logging.getLogger("evoque")

    sets the logger to be used for all evaluation
    independently of the setting of errors,
    evaluation errors are always logged.
    Also, the output of calling inspect(False) from
    within a template are sent to log.info().