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
3 changes: 3 additions & 0 deletions tests/FunctionAwaitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function testAwaitOneRejected()

/**
* @expectedException UnexpectedValueException
* @expectedExceptionMessage Promise rejected with unexpected value of type bool
*/
public function testAwaitOneRejectedWithFalseWillWrapInUnexpectedValueException()
{
Expand All @@ -29,6 +30,7 @@ public function testAwaitOneRejectedWithFalseWillWrapInUnexpectedValueException(

/**
* @expectedException UnexpectedValueException
* @expectedExceptionMessage Promise rejected with unexpected value of type NULL
*/
public function testAwaitOneRejectedWithNullWillWrapInUnexpectedValueException()
{
Expand All @@ -48,6 +50,7 @@ public function testAwaitOneRejectedWithPhp7ErrorWillWrapInUnexpectedValueExcept
Block\await($promise, $this->loop);
$this->fail();
} catch (UnexpectedValueException $e) {
$this->assertEquals('Promise rejected with unexpected value of type Error', $e->getMessage());
$this->assertInstanceOf('Throwable', $e->getPrevious());
$this->assertEquals('Test', $e->getPrevious()->getMessage());
}
Expand Down