On Sep 17, 2008, at 1:33 AM, GustaV wrote:
Hi all! I'm working on a project with turbogears2, and my knowledge in pylons is not big... But it looks like you guys should be able help me :When I raise an exception in a controller (anything but HTTPException), the traceback is writen is the log and the response is redirected to the ErrorDocument (here is 'document' method) to inform the user. I'd like to know what went wrong when I'm in the ErrorDocument, to write an appropriate message to my user. Is it possible to know what was the exception raised? I didn't find anything revelant in the environ variable... Or maybe "raise MyException" is not the best way to do thing... Using 'abort' may be a solution but with less control.
The default error controller provides a clue (not sure if this is in TG2):
resp = request.environ.get('pylons.original_response')
fix = re.compile('^.*?\<body\>(.*?)\<hr.*$', re.S)
c.page = dict(prefix=request.environ.get('SCRIPT_NAME', ''),
code=resp.status_int,
message=re.sub(fix, r'\1', resp.body))
So the original response object is available, and the original_request
is available as well, as environ['pylons.original_request']. If you've
put anything into environ in the original request, like a detailed
accounting of what went wrong, etc. you can of course retrieve that
from the error controller.
Cheers, Ben
smime.p7s
Description: S/MIME cryptographic signature
