[albatross-users] Help catching an exception...

Sheila King sheila at thinkspot.net
Thu Sep 30 04:12:36 EST 2004


Hello,

I'm using Albatross to develop an account management interface for the web
hosting company that I work for.

In the testing process, I have determined that certain type of request urls
will cause Albatross to throw an exception, and I'm trying to catch that
exception to redirect to a public error page of my choosing so that end
users do not see the Python tracebacks.

Mind you, it would be some odd circumstance that would even lead to this
type of error, but I am hoping to cover as many error situations as I can.

The problem is this:

A correct URL for the application might look like this:

http://example.net/cgi-dev/mgr.py/createlogin

But suppose this URL is requested instead:
http://example.net/cgi-dev/mgr.py/mgr.py/createlogin

Then albatross gives the following traceback:
-----
Template traceback (most recent call last):

Traceback (most recent call last):
  File "albatross/app.py", line 279, in run
    self.load_page(ctx)
  File "albatross/randompage.py", line 29, in load_page
    self.load_page_module(ctx, page)
  File "albatross/app.py", line 435, in load_page_module
    raise ApplicationError('%s (in %s)' % (e, mod_dir))
ApplicationError: No module named createlogin (in ./pages/mgr/py)
-----


In the __main__ function of the mgr.py file I tried adding 
a try/except to wrap the whole invocation of an albatross app
(I know...bad programming...but...well...)

Here is the except block I put on:

    except ApplicationError, e:
        Request = "http://www.Example.net/cgi-bin/mgr.py/errorpage"
        app = qaApp()
        ctx = qaAppContext(app)
        ctx.locals._errmssg = e
        app.run(qaRequest(Request))
        
Unfortunately, it appears to be having no effect, and I am still
getting the identical traceback as before.

I also tried changing the "except" statement to

except albatross.ApplicationError, e

and also tried adding an import statement at the top of the code

from albatross.common import AlbatrossError

and changing the except statement to:

except AlbatrossError, e

But again, no change in the traceback produced for that particular URL.


I sure would appreciate any tips on how to catch this error and
redirect to an error page of my choosing...

Thank you,





More information about the Albatross-users mailing list