Ticket #4: foolscap-copiedremoteexception.hgexport.patch

File foolscap-copiedremoteexception.hgexport.patch, 1.2 KB (added by strank, 17 years ago)

updated patch for current trunk

  • foolscap/call.py

    # HG changeset patch
    # User strank(AT)strank(DOT)info
    # Date 1208359077 -7200
    # Node ID a5ee14862f1215ebbaaa457c942319f2c71908f2
    # Parent  ecf45dffc5cb2ebe3d1f64bf61b13aec73fcea90
    add CopiedRemoteException, new-style class to allow catching in except
    
    diff -r ecf45dffc5cb -r a5ee14862f12 foolscap/call.py
    a b  
    820820
    821821        return state
    822822
     823class CopiedRemoteException(Exception):
     824    """I represent an exception thrown on the remote end
     825    (real Exception, old-style instance, or string),
     826    I am a base class for locally reconstructed Exceptions.
     827    You can catch me in a try block if you want.
     828    """
     829
    823830class CopiedFailure(failure.Failure, copyable.RemoteCopyOldStyle):
    824831    # this is a RemoteCopyOldStyle because you can't raise new-style
    825832    # instances as exceptions.
     
    887894
    888895        assert isinstance(self.type, str)
    889896        typepieces = self.type.split(".")
    890         class ExceptionLikeString:
     897        class ExceptionLikeString(CopiedRemoteException):
    891898            pass
    892899        self.type = ExceptionLikeString
    893900        self.type.__module__ = ".".join(typepieces[:-1])