[development] Better error-handling

Johan Forngren johan at forngren.com
Mon Aug 7 20:25:21 UTC 2006


Hi all!

I'm proud to present this patch, http://drupal.org/node/77514.

It does some simple but yet very useful changes to the error reporting 
system. Basicly this is a version of Search404 
(http://drupal.org/node/26010) on steroids, with some enchantments. All 
features from Search 404 are kept. It has been rewritten to be more 
stable, secure and fast than before. New features has been added:

    * The error message is now configurable
    * Three special paths has been added;
          o <blank> - It's the classic Drupal 404 page, just an error
            message
          o <front> - Invokes the frontpage - with an error message set
            to $message
          o <search> - This is what Search 404 accomplishes and is also
            the standard 404 page if nothing else is specified. It
            performs a search on the words from the requested URL. The
            options to configure Search 404 remains:
                + Display a link instead of the search results directly.
                  This feature is particular useful when many bots is
                  hitting the site.
                + Jump directly to the search result when there is only
                  one result.
                + Use OR between keywords when searching.
                + A list of words that should be ignored (php, html etc)
          o Of course any Drupal path can still be specified
    * There's now an option to send "404 Not found" header or not
    * Brand new 403-handling:
          o Can use <blank> and <front>, but also <login> which will
            display a login form.
          o Configurable error message and option to send "403 Access
            denied" header

Care has been taken to not create loops, such as the user don't have 
access to the 404 page, and the 403 page itself isn't found.

One reason why this should be in core, is that error-handling surely is 
someting the CMS itself should take care of.

*How to test:*
1a) Visit: http://forngren.com/fantastic40x/
1b) Make a fresh Drupal HEAD install, and make sure that everything 
seems ok. Apply the patch attched
2) Fool around with the site
3) Report results back in this issue

Links
* http://drupal.org/node/26010 * Search 404

    /Posted by geokker - November 7, 2004 - 11:56 *
    http://drupal.org/node/12668 */
    I can't believe how many sites miss this trick. I was looking for a
    radio programme 'Loose Ends' on the BBC website. I tried
    www.bbc.co.uk/radio/looseends <http://www.bbc.co.uk/radio/looseends>
    and got a 404.

    Why? How difficult would it be to put the non-matching part of the
    URL into a search and bring up 'Sorry, we couldn't find an exact
    match - did you mean...' then list trip_search results or something.

    *If anyone can figure this out, it should go into core Drupal
    functionality.*

    A good CMS has an excellent search facility.

    A good site has this search facility on every page.

    When I'm looking for something on a site, as soon as it renders I
    instantly judge it. If I can't quickly see a search box - I hate it.
    If there is a ton of content on the front page - I'm not a fan. If
    the search is slow, or doesn't yield coherent results - I'm
    dissapointed. If it's Flash - I'm not impressed.

* http://drupal.org/node/7570 * Diskussion about "Custom 404 Error Page"

*Sideeffect*
There is a tiny sideeffect, though. After using this for a few days on a 
test site with 6 nodes, I stopped using the navigation and just typed 
what I was looking for in the URL. I think that Bert Boerland can 
confirm this.

*Final words, contact info and more*
First of all, none of this would be possible if it wasn't for the work 
done by Lars Sehested Geisler/larssg, the maintainer of Search 404, and 
Bert Boerland, which has been a great support during the process of 
writing, testing and documenting this patch. Since I've summerholidays I 
can usually fix bugs/errors within a few hours (awake between 10-24 GTM 
+2). If you want to discuss this patch, please, do so. I'm in #drupal 
when I'm awake. You can also use my contact form 
(http://drupal.org/user/40238/contact) or skype me (forngren).

Cheers!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20060807/4d24b872/attachment-0001.htm


More information about the development mailing list