Prev | Index | Next

Example of error handling

# blocking code:
# def f():
#   try:
#     return foo()
#   except ValueError:
#     return blah()

def handleError(failure):
    failure.trap(ValueError)
    return blah()

def f():
    d = foo()
    return d.addErrback(handleError)