function PromiseInterface::catch
Registers a rejection handler for promise. It is a shortcut for:
```php $promise->then(null, $onRejected); ```
Additionally, you can type hint the `$reason` argument of `$onRejected` to catch only specific errors.
@template TThrowable of \Throwable @template TRejected
Parameters
callable(TThrowable): (PromiseInterface<TRejected>|TRejected) $onRejected:
Return value
PromiseInterface<T|TRejected>
3 methods override PromiseInterface::catch()
- FulfilledPromise::catch in vendor/
react/ promise/ src/ Internal/ FulfilledPromise.php - Registers a rejection handler for promise. It is a shortcut for:
- Promise::catch in vendor/
react/ promise/ src/ Promise.php - @template TThrowable of \Throwable @template TRejected
- RejectedPromise::catch in vendor/
react/ promise/ src/ Internal/ RejectedPromise.php - @template TThrowable of \Throwable @template TRejected
File
-
vendor/
react/ promise/ src/ PromiseInterface.php, line 57
Class
- PromiseInterface
- @template-covariant T
Namespace
React\PromiseCode
public function catch(callable $onRejected) : PromiseInterface;