Skip to content

Commit

Permalink
improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ata-no-one committed Oct 14, 2024
1 parent eb70b8c commit ec92daf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion php/src/vaas/VaasConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ public function build(): VaasConnection {
}
$this->loop = async(function() {
$this->handleResponse();
})->catch(function($e) {
$this->logger->error("Error", ["error" => $e]);
$futures = $this->responses->getIterator();
foreach($futures as $future) {
$future->error($e);
}
});
if (isset($this->authenticator)) {
$this->Connect();
Expand Down Expand Up @@ -172,6 +178,7 @@ public function setTimeout(int $timeoutInSeconds): void {

private function handleResponse(): void {
$mapper = new JsonMapper();
$mapper->bStrictObjectTypeChecking = false;
$connection = $this->GetConnectedWebsocket();
while ($message = $connection->receive($this->loopCancellation->getCancellation())) {
if ($message == null) continue;
Expand Down Expand Up @@ -220,7 +227,6 @@ private function handleResponse(): void {
throw new VaasServerException("Unknown message kind: " . $baseMessage->kind);
};
} catch (JsonMapper_Exception $e) {
$this->logger->error("Error", ["error" => $e]);
throw new VaasServerException("Error parsing received message: " . $e->getMessage());
}
}
Expand Down

0 comments on commit ec92daf

Please sign in to comment.