Acting on HTTP errors

cover image for Acting on HTTP errors

How not to handle Midgard errors
Since Midgard does now Python nicely alongside PHP, some Midgardians have recently been looking at Django as an optional web framework to use with Midgard's replicated storage system.

Looking at other systems than yours every now and then is great, as you can get some ideas. First such idea to come to Midgard from the Django world is error interceptors, a set of configurable actions to perform on given types of errors. For a long time, Midgard has been mapping various types of system errors (and in MidCOM3, Exceptions) to various HTTP status codes, and has made it possible to create customized templates for displaying them.

Error interceptors, on the other hand, allow other actions to take place. Some examples:

  • Log all 404 Not Found page URLs into a special log file alongside their referrers
  • Send all 500 Internal Errors with debug stacktrace to the site developer

This feature just landed into Midgard SVN and will be available in the 8.09.3 release due out next week. To enable those mentioned features, tweak your MidCOM config in the following way:

$GLOBALS['midcom_config_local']['error_actions'] = array
(
    500 => array
    (
        'action' => 'email',
        'email' => 'webmaster@example.net',
    ),
    404 => array
    (
        'action' => 'log',
        'filename' => '/var/log/broken_links.log',
    ),
);

Technorati Tags: , ,


Read more Midgard posts.