Skip to content

Commit 07b7afd

Browse files
committed
Improve and fix documentation of CompositeException used in some() and any()
1 parent bfe3e98 commit 07b7afd

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,9 @@ Returns a promise that will resolve when any one of the items in
422422
will be the resolution value of the triggering item.
423423

424424
The returned promise will only reject if *all* items in `$promisesOrValues` are
425-
rejected. The rejection value will be an array of all rejection reasons.
425+
rejected. The rejection value will be a `React\Promise\Exception\CompositeException`
426+
which holds all rejection reasons. The rejection reasons can be obtained with
427+
`CompositeException::getExceptions()`.
426428

427429
The returned promise will also reject with a `React\Promise\Exception\LengthException`
428430
if `$promisesOrValues` contains 0 items.
@@ -440,8 +442,9 @@ triggering items.
440442

441443
The returned promise will reject if it becomes impossible for `$howMany` items
442444
to resolve (that is, when `(count($promisesOrValues) - $howMany) + 1` items
443-
reject). The rejection value will be an array of
444-
`(count($promisesOrValues) - $howMany) + 1` rejection reasons.
445+
reject). The rejection value will be a `React\Promise\Exception\CompositeException`
446+
which holds `(count($promisesOrValues) - $howMany) + 1` rejection reasons.
447+
The rejection reasons can be obtained with `CompositeException::getExceptions()`.
445448

446449
The returned promise will also reject with a `React\Promise\Exception\LengthException`
447450
if `$promisesOrValues` contains less items than `$howMany`.

src/Exception/CompositeException.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
namespace React\Promise\Exception;
44

5+
/**
6+
* Represents an exception that is a composite of one or more other exceptions.
7+
*
8+
* This exception is useful in situations where a promise must be rejected
9+
* with multiple exceptions. It is used for example to reject the returned
10+
* promise from `some()` and `any()` when too many input promises reject.
11+
*/
512
class CompositeException extends \Exception
613
{
714
private $exceptions;

0 commit comments

Comments
 (0)