diff --git a/src/ChildProcess/Adapter.php b/src/ChildProcess/Adapter.php index 65ed53a0..45fdd484 100644 --- a/src/ChildProcess/Adapter.php +++ b/src/ChildProcess/Adapter.php @@ -130,8 +130,8 @@ public function callFilesystem($function, $args, $errorResultCode = -1) { return $this->pool->rpc(Factory::rpc($function, $args))->then(function (Payload $payload) { return \React\Promise\resolve($payload->getPayload()); - }, function (Payload $payload) { - return \React\Promise\reject(new Exception($payload->getPayload()['error']['error']['message'])); + }, function ($payload) { + return \React\Promise\reject(new Exception($payload['error']['message'])); }); } diff --git a/tests/ChildProcess/AdapterTest.php b/tests/ChildProcess/AdapterTest.php index 3a27d5be..8fbbf83d 100644 --- a/tests/ChildProcess/AdapterTest.php +++ b/tests/ChildProcess/AdapterTest.php @@ -2,6 +2,7 @@ namespace React\Tests\Filesystem\ChildProcess; +use React\EventLoop\Factory; use React\Filesystem\ChildProcess\Adapter; use React\Filesystem\Filesystem; use React\Filesystem\Node\NodeInterface; @@ -324,4 +325,17 @@ public function testLs() ]); $this->assertTrue($calledOnData); } + + public function testErrorFromPool() + { + $this->setExpectedException('\Exception', 'oops'); + + $loop = Factory::create(); + $adapter = new Adapter($loop, [ + 'pool' => [ + 'class' => 'React\Tests\Filesystem\ChildProcess\PoolRpcErrorMockFactory', + ], + ]); + $this->await($adapter->touch('foo.bar'), $loop, 1); + } } diff --git a/tests/ChildProcess/PoolRpcErrorMock.php b/tests/ChildProcess/PoolRpcErrorMock.php new file mode 100644 index 00000000..d029a836 --- /dev/null +++ b/tests/ChildProcess/PoolRpcErrorMock.php @@ -0,0 +1,44 @@ + [ + 'message' => 'oops', + ], + ]); + } + + public function message(Message $message) + { + return new FulfilledPromise(); + } + + public function terminate(Message $message, $timeout = 5, $signal = null) + { + return new FulfilledPromise(); + } + + public function info() + { + return []; + } +} diff --git a/tests/ChildProcess/PoolRpcErrorMockFactory.php b/tests/ChildProcess/PoolRpcErrorMockFactory.php new file mode 100644 index 00000000..4ff77615 --- /dev/null +++ b/tests/ChildProcess/PoolRpcErrorMockFactory.php @@ -0,0 +1,32 @@ +