def callAndFulfill(v): """ A callback to be invoked if the "self promise" is fulfilled. """ try: if aplus._isFunction(success): ret.fulfill(success(v)) else: ret.fulfill(v) except Exception as e: Promise.last_exc_info = sys.exc_info() e.exc_info = sys.exc_info() ret.reject(e)
def callAndReject(r): """ A callback to be invoked if the "self promise" is rejected. """ try: if aplus._isFunction(failure): ret.fulfill(failure(r)) else: ret.reject(r) except Exception as e: Promise.last_exc_info = sys.exc_info() e.exc_info = sys.exc_info() ret.reject(e)