Skip to content

Commit bfe3e98

Browse files
committed
Remove custom InvalidArgumentException class
1 parent 8b56118 commit bfe3e98

File tree

3 files changed

+8
-20
lines changed

3 files changed

+8
-20
lines changed

src/Exception/InvalidArgumentException.php

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/RejectedPromise.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22

33
namespace React\Promise;
44

5-
use React\Promise\Exception\InvalidArgumentException;
6-
75
final class RejectedPromise implements PromiseInterface
86
{
97
private $reason;
108

119
public function __construct($reason)
1210
{
1311
if (!$reason instanceof \Throwable && !$reason instanceof \Exception) {
14-
throw InvalidArgumentException::invalidRejectionReason($reason);
12+
throw new \InvalidArgumentException(
13+
sprintf(
14+
'A Promise must be rejected with a \Throwable or \Exception instance, got "%s" instead.',
15+
is_object($reason) ? get_class($reason) : gettype($reason)
16+
)
17+
18+
);
1519
}
1620

1721
$this->reason = $reason;

tests/RejectedPromiseTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function getPromiseTestAdapter(callable $canceller = null)
4444
/** @test */
4545
public function shouldThrowExceptionIfConstructedWithANonException()
4646
{
47-
$this->setExpectedException('\React\Promise\Exception\InvalidArgumentException');
47+
$this->setExpectedException('\InvalidArgumentException');
4848

4949
return new RejectedPromise('foo');
5050
}

0 commit comments

Comments
 (0)