Error handling fixes
This commit is contained in:
@ -73,8 +73,8 @@ class CommandBusClient implements CommandBusInterface
|
||||
function (DuplexStreamInterface $connection) {
|
||||
$this->connection = $connection;
|
||||
$this->emit(self::EVENT_CONNECTED);
|
||||
$connection->on('error', function () {
|
||||
$this->emit(self::EVENT_DISCONNECTED);
|
||||
$connection->on('error', function ($error) {
|
||||
$this->emit(self::EVENT_DISCONNECTED, [ $error ]);
|
||||
if ($this->autoReconnect) {
|
||||
Loop::addTimer(1, $this->reconnect(...));
|
||||
}
|
||||
@ -124,15 +124,14 @@ class CommandBusClient implements CommandBusInterface
|
||||
$this->emit(self::EVENT_NOTIFY, [ $event, $data ]);
|
||||
break;
|
||||
case Message::MSGTYPE_ERROR: // error
|
||||
var_dump($message);
|
||||
$uuid = $message->getUuid();
|
||||
$error = $message->getData()['error'];
|
||||
if ($uuid === "") {
|
||||
$this->emit('error', [ $error ]);
|
||||
if ($uuid && array_key_exists($uuid, $this->pending)) {
|
||||
$this->pending[$uuid]->reject(new \Exception($error));
|
||||
unset($this->pending[$uuid]);
|
||||
} else {
|
||||
if (array_key_exists($uuid, $this->pending)) {
|
||||
$this->pending[$uuid]->reject(new \Exception($error));
|
||||
unset($this->pending[$uuid]);
|
||||
}
|
||||
$this->emit('error', [ $error ]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
Reference in New Issue
Block a user