The standard system error pages can be overriden by adding specially-named and constructed files to the template directory. For example, this could be used to style the error pages so that they match the style of regular pages for the template.
Placing one or more of the following files into the templates/<template-name> directory will override the similarly named file in the templates/system directory.
To render the error backtrace information when debugging mode is on you can call the renderBacktrace method like this:
<?php if ($this->debug) : echo $this->renderBacktrace(); endif; ?>
Note that jdoc:include elements are not parsed in these error pages.