[Nitro] param handling

Kirk Haines wyhaines at gmail.com
Tue Oct 24 14:44:23 EDT 2006

On 10/24/06, Jonathan Buch <john at oxyliquit.de> wrote:

> Slightly unrelated idea:
> How about different error pages for different errors?  Like when a
> ArgumentError is getting raised, or when a NameError occurs (404)....
> Something like a hash with error classes and or error codes...

Jonathan, in IRC, encouraged me to jump in here, too.

I've had this capability in IOWA for a long time, and while I've only
really needed to use the ability to display different pages for
different errors a couple times, it was _very_ handy to have it when I
needed it.

The way that it works in IOWA is pretty simple.

In the configuration for the app, one can have a 'screens' section.
A simple might look like this:

  - /.*/: GeneralException

What that says is that if there is an error processing a request, the
GeneralException component will be given control of the request if the
class of the exception matches the regular expression.  That could
also be expressed as:

  - Exception: GeneralException

That would specifically match any exception class that has Exception
as one of its ancestors.

The code simply iterates through the exception screens that are
defined, looking for the first one that matches.  One can have any
number of them.


  - UnauthorizedAccess: SecurityViolation
  - /^ExternalApp/: ExternalAppError
  - Exception: GeneralException

Would specify that if an UnauthorizedAccess exception were thrown,
SecurityViolation would get the request.  If any of several different
kinds of exceptions with class names starting with ExternalApp,
ExternalAppError would handle those, and everything else would fall to

It's a simple mechanism, but my experience with it is very positive.

Kirk Haines

More information about the Nitro-general mailing list