Catching Errors

Gerson Kurz gerson.kurz at t-online.de
Fri Jun 8 13:44:45 EDT 2001


On Fri, 08 Jun 2001 16:25:06 +0200, mixo <mixo77 at usa.net> wrote:

>
>How can I  catch errors that I are usually written to standard output?

I use this to display errors that my CGI BIN raises on the website
itself (and not in apaches logfile), so the situation is very similar.



class myerrorhandler:
    def write(self,x):
        print '<font size="4" color="#FF0000"><b>',x,"</b></font><br>"

import sys
output = myerrorhandler()
sys.stderr = output


All you need to do is implement your own write() func.



More information about the Python-list mailing list