from twisted.internet.defer import Deferred

def got_poem(res):
    print 'Your poem is served:'
    print res

def poem_failed(err):
    print err.__class__
    print err
    print 'No poetry for you.'

d = Deferred()

# add a callback/errback pair to the chain
d.addCallbacks(got_poem, poem_failed)

# fire the chain with an error result
d.errback(Exception('I have failed.'))

#<class 'twisted.python.failure.Failure'>
#[Failure instance: Traceback (failure with no frames): <type 'exceptions.Exception'>: I have failed.
#]
#No poetry for you.
