IVLEError exception standards are ugly and unPythonic

Bug #492480 reported by William Grant
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fix Released
William Grant

Bug Description

IVLE apps currently seem to be discouraged from letting any exception
escape them other than an IVLEError. This results in lots of 'except
Exception, e:', which is unthinkably bad.

Lumping all HTTP errors into IVLEError is also very strange. We should
probably instead create a root HTTP error class and subclasses like
BadRequest, NotFound, Forbidden which specify the numeric code and default

For example, what was previously:

    req.throw_error(req.HTTP_BAD_REQUEST, 'the foo isn't valid')


    raise BadRequest('the foo isn't valid')

... which is far more obvious and prettier.

We should also alter the standards to recommend that applications do not
trap errors except those that they know are likely to happen, and are not

For example: if an exception is caused by a user specifying a URL argument
with the wrong type, it should be caught and a BadRequest raised. If an
exception occurs during a normal piece of code, it should be allowed to
bubble up to the root handler without being touched by the app.

This should reduce code nesting depth, shorten it somewhat, and allow more
useful error logs - calling req.throw_error() instead of raising directly
causes the traceback and some exception information to be lost.

Revision history for this message
William Grant (wgrant) wrote :

All views ported to the new dispatch framework have the exceptions corrected.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers