[albatross-users] Defining an "error" page...

Dave Cole djc at object-craft.com.au
Wed Sep 18 10:38:07 EST 2002


> In JavaServer Pages (JSP), you have the ability to specify a page to
> which the user is forwarded if there is an unrecoverable error.  This is
> commonly used to send the user to a page that says "There has been an
> error.  Please call the site administrator." rather than expose the user
> to the raw Python error displays, such as:
> 
> Template traceback (most recent call last):
> 
> Traceback (most recent call last):
>   File "/usr/lib/python2.1/site-packages/albatross/app.py", line 146, in run
>       self.process_request(ctx)
>   File "/usr/lib/python2.1/site-packages/albatross/app.py", line 296, in process_request func(ctx)
>   File "prop_list.py", line 25, in page_process
>       aContext.set_page(page)
>   File "/usr/lib/python2.1/site-packages/albatross/app.py", line 86, in set_page
>       self.app.load_page(self)
>   File "/usr/lib/python2.1/site-packages/albatross/app.py", line 253, in load_page
>       self.load_page_module(ctx, name)
>   File "/usr/lib/python2.1/site-packages/albatross/app.py", line 268, in load_page_module
>       file, filepath, desc = imp.find_module(name, [dirname])
> ImportError: No module named bob
> 
> 
> Is there any way to achieve the same functionality in Albatross?

If you look in app.py at the handle_exception() method of the
Application class you will see how it performs the exception reporting
you are seeing.  All Albatross application classes inherit from
Application.  You have two options for changing what you see:

1) Provide a template file called traceback.html which contains the
   text you want the user to see.

2) Subclass the Albatross application object and override the
   handle_exception() method.  You could make your version report the
   traceback to a log file, send email, whatever takes your fancy.

- Dave

-- 
http://www.object-craft.com.au




More information about the Albatross-users mailing list