Improve error handling
This commit is contained in:
@ -121,6 +121,18 @@ class CommandBusClient implements CommandBusInterface
|
||||
$data = (array)($message->getData()['data']??[]);
|
||||
$this->emit(self::EVENT_NOTIFY, [ $event, $data ]);
|
||||
break;
|
||||
case Message::MSGTYPE_ERROR: // error
|
||||
$uuid = $message->getUuid();
|
||||
$error = $message->getData()['error'];
|
||||
if ($uuid === "") {
|
||||
$this->emit('error', [ $error ]);
|
||||
} else {
|
||||
if (array_key_exists($uuid, $this->pending)) {
|
||||
$this->pending[$uuid]->reject(new \Exception($error));
|
||||
unset($this->pending[$uuid]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->connection->end('{"msg":"error","data":{"error":"Unexpected message type"}}');
|
||||
}
|
||||
|
Reference in New Issue
Block a user