ErrorDocument

3 views
Skip to first unread message

GustaV

unread,
Sep 15, 2008, 5:00:24 AM9/15/08
to TurboGears
It seems the exception_handler was replaced by the special
ErrorDocument controller. The document method being where the thing
happen when an exception occurs.
But any change in that method is not reflected in real world (event
make it empty) : is there something to do to reference that class?

Cheers,
GustaV

GustaV

unread,
Sep 16, 2008, 4:10:45 AM9/16/08
to TurboGears
Up! : )

Christopher Arndt

unread,
Sep 16, 2008, 8:12:45 AM9/16/08
to turbo...@googlegroups.com

Hi Gustav,

after reading your post several times, I still fail to grasp its
meaning. Can you elaborate?

- Are you talking about TG2 or TG1?
- Do you have a specific problem, i.e. non-working-code, that needs to
be solved? Can you provide that code?

Chris

GustaV

unread,
Sep 16, 2008, 12:01:34 PM9/16/08
to TurboGears
Sorry if I wasn't clear!

Working on TG2, I'd like to handle exception thown by my code.
Today, when I throw an exception, I can see it in the apache or paster
log; but I have no control about what the user can see on his browser.
It is always a HTML saying "404 error blablabla", no matter it is
actually a 403, a 500, and no explanation about what went wrong.

In TG2 there is apparently no exception_handler like in TG1, it looks
like it is replaced by the ErrorController class generated in a
quickstart project. The method 'document' seems to be responsible for
the display of the error on the client side. So I tried to modify it
to return JSON instead of HTML and more precise error message,
depending on the exception...
But anything I can modify in that method doesn't change the behavior
of error messaging : it is always HTML 404 code.

So it looks like the class ErrorController is actually not used at
all, does not override any default (Pylons?) error manager.

You can check yourself: raise an exception in
ErrorController.document() : nothing special happen.


GustaV

Jonathan LaCour

unread,
Sep 16, 2008, 1:40:46 PM9/16/08
to turbo...@googlegroups.com
GustaV wrote:

> So it looks like the class ErrorController is actually not used at
> all, does not override any default (Pylons?) error manager.
>
> You can check yourself: raise an exception in
> ErrorController.document() : nothing special happen.

This is a bug in the default template. The ErrorController should
not inherit from BaseController, which is a special TurboGears
controller and screws up routing. You want it to inherit from
WSGIController:

from pylons.controllers import WSGIController

class ErrorController(WSGIController):
...

I had this very problem just yesterday, but this fixed it, and now I
am getting my customized error document when problems arise.

--
Jonathan LaCour
http://cleverdevil.org

GustaV

unread,
Sep 16, 2008, 3:15:18 PM9/16/08
to TurboGears
Thank you!

Another silly question : how can I know the exception that was raised
while in the 'document' method? It would be useful to write my error
message...
In the environ variable, except 'paste.evalexception' (which doesn't
seems to be what I want) nothing looks like an exception report!

On Sep 16, 7:40 pm, Jonathan LaCour <jonathan-li...@cleverdevil.org>
wrote:

Jonathan LaCour

unread,
Sep 16, 2008, 3:22:26 PM9/16/08
to turbo...@googlegroups.com
GustaV wrote:

> Another silly question : how can I know the exception that
> was raised while in the 'document' method? It would be useful
> to write my error message... In the environ variable, except
> 'paste.evalexception' (which doesn't seems to be what I want)
> nothing looks like an exception report!

I don't have an answer to that particular question. You might want
to ask that on the Pylons list.

However, I can tell you what I do, which is to configure the error
handler to send an email to a special address with the full error
message, trace back, WSGI environment, etc. I also configure the
error handler to write all this information to a log file on the
servers: You can do the same using the following configuration
parameters:

from_address = err...@yourdomain.com
email_to = err...@yourdomain.com
smtp_server = localhost
error_subject_prefix = Application Error:
error_log = /tmp/error.log

Best of luck to you.

Reply all
Reply to author
Forward
0 new messages