Wyant, Jaime
jwyant at sfbcic.com
Fri Nov 8 16:06:58 EST 2002
>>>-----Original Message----- >>>From: Conrad Steenberg [mailto:conrad at hep.caltech.edu] >>>Sent: Friday, November 08, 2002 3:32 PM >>>To: Wyant, Jaime >>>Cc: 'mod_python at modpython.org' >>>Subject: Re: [mod_python] Grabbing the callback object >>> >>> >>>Hi Jaime >>> >>>You can write your own error message to the client, and return >>>apache.DONE to stop Apache from any further processing. >>> >>>E.g. >>> >>>def handler(req): >>> try: >>> <Do some processing> >>> except: >>> <Write error message, including headers> >>> return apache.DONE >>> >>> return apache.OK >>> >>> >>>Cheers! >>> >>>Conrad >>> Thanks! I thought about doing it that way. Take a peek at a snippet of my error log: [Tue Nov 5 07:36:13 2002] [error] PythonHandler mod_python.publisher: File "/ usr/local/lib/python2.2/site-packages/mod_python/publisher.py", line 88, in hand ler if func_path[-1] == ".": [Tue Nov 5 07:36:13 2002] [error] PythonHandler mod_python.publisher: IndexErro r: string index out of range [Tue Nov 5 08:09:44 2002] [error] PythonHandler mod_python.publisher: Traceback (most recent call last): I'm getting an IndexError in the publisher module. I have already modified that module a little bit already and would rather not change it any more. No, my changes aren't causing the IndexError :). I simply modified the handler to "raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND" when an ImportError occurred. This stopped "mostly correct" paths from returning an "Internal Server Error Message". I can elaborate if you are curious. Maybe I could create a wrapper handler for the publisher handler? # my wrapper import mod_python.publisher def handler( req ): try: return mod_python.publisher.handler( req ) except Exception: req.write( create_cool_html_error_report() ) return apache.OK Thanks! jaime >>>On Fri, 2002-11-08 at 12:16, Wyant, Jaime wrote: >>>> Hi all! >>>> >>>> Is there any way to grab the Callback object? I really >>>want to override the >>>> "ReportError" method and generate a more meaningful error >>>message with >>>> pretty graphics. >>>> >>>> Better yet, is there a way to catch unhandled exceptions >>>and display a >>>> custom error message? >>>> >>>> thanks! >>>> >>>> jaime wyant (jwyant at sfbcic . com) >>>> MS Farm Bureau >>>> (601) 977 - 4291 >>>> >>>> >>>> _______________________________________________ >>>> Mod_python mailing list >>>> Mod_python at modpython.org >>>> http://www.modpython.org/mailman/listinfo/mod_python >>>-- >>>*-----------------------------------------* >>>| Conrad Steenberg | >>>| Caltech, Mail Code 356-48 | >>>| Pasadena, CA, 91125 | >>>| e-mail: conrad at hep.caltech.edu | >>>| Tel: (626) 395-8758 | >>>*-----------------------------------------* >>> >>>_______________________________________________ >>>Mod_python mailing list >>>Mod_python at modpython.org >>>http://www.modpython.org/mailman/listinfo/mod_python >>>
|