With the 0.2.6 release of Scorpio, a new MVC component was added - the mvcErrorController. This controller is principally used in the base sites distributorDispatcher and now allows error pages to be properly templated using the normal MVC template engine of the site.
This change has removed the need for static .OUTPUT template files in the views root folder and instead there is now an "error" folder. Several views are available by default, however both the error controller and the view can be extended to add or modify the behaviour.
The default views are:
An additional template 'debug' is provided for outputting debug information in development environments. It is used in the 500 error template.
In keeping with the Scorpio template system, additional .xml.tpl or other output templates can be customised to provide useful responses for those error types. By default only HTML is included.
Three of these templates should be familiar: invalidRequest, invalidAction and offline are inherited from the previous system. These are used when the request cannot be routed - either no controller in the controller map or the controller object could not be created from the map, or the controller map is damaged. invalidAction is from a valid controller, but the action is not supported. Finally 'offline' is well, when a site is in-active, down for maintenance or is somehow otherwise not available (e.g. DB offline).
These existing templates are joined by three new ones: 500, 503 and 404. These represent the HTTP error codes of 'Internal Server Error', 'Server Gone Away' and 'Request/Resource Not Found' respectively. It should be noted that the actual HTTP status code is not sent with these templates.
Off the new templates, 500 is perhaps the most useful. This is now the default output handler for any un-handled exceptions raised during the request process. Previously these were handled rather ungraciously and routed to a 'static' page. These pages were hard-coded and outside the template system making additional work to keep them up-to-date. In development mode, the exception was simply dumped out to the browser and execution terminated. Now, the exception is injected into the error view and additional functionality can be added to it such as source code highlighting using the new Smarty plugin or interactive stack tracing etc. How the error information is displayed is now completely up to the site maintainer. Of course the debugging data is only available in a non-production environment. When isProduction is set to true, it is all suppressed but still logged via the systemLog instance.
Next we look at how to customise these new templates.
Posted by: Dave Redfern (Writer), in MVC on 07 Sep 2009 @ 18:50
Tags: documentation, mvcerrorcontroller,
Contents:
This
work is licenced under a
Creative Commons Licence.