开发者

How can i extract failure condition in Twisted

In my program i have method that handles all errors. Something like this

def _processError(self, failure):
    ''' Process various errors '''
    if isinstance(failure, Failure):
        error = failure.trap(SASLAuthError, StanzaError)
        if error == SASLAuthError:
            self.notifyObservers(error = 'authorization')
        elif error == StanzaError:
            self.notifyObservers(error = 'subscription')

I need to implement more specific information about failures (condition). One way is to call getErrorMessage and parse a string . But this is not very开发者_如何学Go good because of possibility of changing error format in Twisted. Does anyone have any ideas?


You should use callback and errback chains (with the help twisted.internet.defer module) to handle error conditions while programming with twisted.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜