public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onCancel = null)
{
if (null === $onFulfilled) {
return $this;
}
try {
return Promise::doResolve($onFulfilled($this->getValue()));
} catch (Error $ex) {
return new PromiseRejected($ex);
} catch (Exception $ex) {
return new PromiseRejected($ex);
}
}