Exception Templates

Exception templates are rendered when an unhandled exception occurs during the request processing. Exception templates can be configured in app/config/settings.xml and overwritten in app/config/output_types.xml. The configuration in settings.xml aims at setting up a reasonable default and is used if no configuration can be loaded from output_types.xml. This can happen in a variety of cases:


  • The error occurs before the configuration from output_types.xml is loaded, i.e. during the framework bootstrap.
  • There is no specific configuration for the active output type in output_type.xml

Configuration in settings.xml

The configration in settings.xml uses a special <exception_templates> block. Each entry can contain a context name and must specify a valid path to an exception template. The entry with an empty name is used as default for all contexts.

<exception_templates>
  <exception_template>%core.agavi_dir%/exception/templates/shiny.php</exception_template>
  <exception_template context="console">%core.agavi_dir%/exception/templates/plaintext.php</exception_template>
</exception_templates>
CAUTION:
While the shiny exception template provides a beautiful stacktrace and is very useful for debugging we strictly recommend against using it in production. Design your own error template an log the error instead of displaying it to the user.

Configuration in output_types.xml

The <output_type> tag can have an optional exception_template attribute, it contains the path to the template to use for this specific output type. The value supersedes any value from settings.xml.