Re: Changing page-level error handler

"Jonathan Ellis" <[email protected]> Tue, 30 Jan 2007 13:45:02 -0800
Newsgroups gmane.comp.python.spyce.general
Message-ID <[email protected]>
Hi Iwan,

I'm digging into the error stuff again since it seems to confuse a lot
of people and will probably get some kind of rewrite for 2.2.  The short
version is,

* error.serverHandler [or errorhandler in your config] gets called ONLY
for compile-time errors
* error.spyceHandler gets called ONLY for run-time errors

Currently you can only override error.spyceHandler by calling
"error.setHandler" on a per-page basis in your .spy files.  (Or by
editing modules/error.py.)

Manually raising an exception is a run-time error so setting
errorhandler has no effect.

On Mon, 25 Dec 2006 10:16:29 +0200, "Iwan Vosloo" <[email protected]> said:
> Sorry, but I still don't get it - it does not seem that the server-level
> error handler is called for Python exceptions.  Here's my test...  I
> have copied the spyceconf.py as shipped and just changed the following:
> 
> #import error
> #errorhandler = error.serverHandler
> def reraisingHandler(theServer, theRequest, theResponse, theError):
>     raise theError
> errorhandler = reraisingHandler
> 
> I then run spyceCmd.py --conf that_changed_spyceconf.py afile.spy
> 
> afile.spy just has a line:
> 
> [[ raise 'some error' ]]
> 
> 
> But it still returns an html page, instead of just raising the
> exception:
> <html>
> <title>Spyce exception: some error
> </title>
> <body>
> <table cellspacing=10 border=0>
>   <tr><td colspan=2><h1>Spyce exception</h1></td></tr>
>   <tr><td valign=top
> align=right><b>File:</b></td><td>/home/iwan/work/play.d/spyce/exc/afile.spy</tr>
>   <tr><td valign=top align=right><b>Message:</b></td>
>     <td><pre>some error
> </pre></tr>
>   <tr><td valign=top align=right><b>Stack:</b></td><td>
>       afile.spy:2, in (main):<br>
>       <table border=0><tr><td width=10></td><td>
>         <pre>raise 'some error'</pre>
>       </td></tr></table>
>     </td></tr>
> </table>
> </body></html>
> 
> 
> 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV