| @@ 44-63 (lines=20) @@ | ||
| 41 | * @override |
|
| 42 | * @inheritDoc |
|
| 43 | */ |
|
| 44 | public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onCancel = null) |
|
| 45 | { |
|
| 46 | if (null === $onFulfilled) |
|
| 47 | { |
|
| 48 | return $this; |
|
| 49 | } |
|
| 50 | ||
| 51 | try |
|
| 52 | { |
|
| 53 | return Promise::doResolve($onFulfilled($this->getValue())); |
|
| 54 | } |
|
| 55 | catch (Error $ex) |
|
| 56 | { |
|
| 57 | return new PromiseRejected($ex); |
|
| 58 | } |
|
| 59 | catch (Exception $ex) |
|
| 60 | { |
|
| 61 | return new PromiseRejected($ex); |
|
| 62 | } |
|
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * @override |
|
| @@ 46-65 (lines=20) @@ | ||
| 43 | * @override |
|
| 44 | * @inheritDoc |
|
| 45 | */ |
|
| 46 | public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onCancel = null) |
|
| 47 | { |
|
| 48 | if (null === $onRejected) |
|
| 49 | { |
|
| 50 | return $this; |
|
| 51 | } |
|
| 52 | ||
| 53 | try |
|
| 54 | { |
|
| 55 | return Promise::doResolve($onRejected($this->getReason())); |
|
| 56 | } |
|
| 57 | catch (Error $ex) |
|
| 58 | { |
|
| 59 | return new PromiseRejected($ex); |
|
| 60 | } |
|
| 61 | catch (Exception $ex) |
|
| 62 | { |
|
| 63 | return new PromiseRejected($ex); |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * @override |
|