Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function ($error) use (&$exception, &$rejected, &$wait, $loop) {
if ($rejected) {
if (!$exception instanceof \Exception) {
$exception = new \UnexpectedValueException(
'Promise rejected with unexpected value of type ' . (is_object(($exception) ? get_class($exception) : gettype($exception))),
'Promise rejected with unexpected value of type ' . (is_object($exception) ? get_class($exception) : gettype($exception)),
0,
$exception instanceof \Throwable ? $exception : null
);
Expand Down
12 changes: 12 additions & 0 deletions tests/FunctionAwaitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ public function testAwaitOneRejectedWithPhp7ErrorWillWrapInUnexpectedValueExcept
}
}

/**
* @expectedException UnexpectedValueException
* @expectedExceptionMessage type string
*/
public function testAwaitRejectedWithStringGivesUnexpectedValueException()
{
$promise = Promise\reject('Test');

Block\await($promise, $this->loop);
$this->fail();
}

public function testAwaitOneResolved()
{
$promise = $this->createPromiseResolved(2);
Expand Down