'Handles errors in the Dispatch method.
When a Dispatch method call fails, this method is called to handle
the exception.  The default implementation formats the traceback
in the browser.'

def HandleDispatchError(self, ecb):

    ecb.HttpStatusCode = isapicon.HSE_STATUS_ERROR
    (exc_typ, exc_val, exc_tb) = sys.exc_info()
    limit = None
    try:
        import cgi
        ecb.SendResponseHeaders('200    OK', 'Content-type:    text/html\r\n\r\n', False)
        print >>ecb
        print >>ecb, '<H3>Traceback    (most    recent    call    last):</H3>'
        list = (traceback.format_tb(exc_tb, limit) + traceback.format_exception_only(exc_typ, exc_val))
        print >>ecb, ('<PRE>%s<B>%s</B></PRE>' % (cgi.escape(''.join(list[:(-1)])), cgi.escape(list[(-1)])))
    except ExtensionError:
        pass
    except:
        print 'FAILED    to    render    the    error    message!'
        traceback.print_exc()
        print 'ORIGINAL    extension    error:'
        traceback.print_exception(exc_typ, exc_val, exc_tb)
    finally:
        exc_tb = None
        ecb.DoneWithSession()
