def checkValueError(f): f.trap(ValueError) return "foo" def getFoo(): d = getResult() d.addErrback(checkValueError) d.addCallback(process) return d