Skip to content

Commit

Permalink
explicitly passed previous exception during fetching of routing table
Browse files Browse the repository at this point in the history
  • Loading branch information
transistive committed Nov 4, 2023
1 parent d7b48f0 commit 543cc52
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Neo4j/Neo4jConnectionPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public function acquire(SessionConfiguration $config): Generator
$table = $this->cache->get($key, null);
$triedAddresses = [];

$latestError = null;

if ($table == null) {
$addresses = $this->resolver->getAddresses((string) $this->data->getUri());
foreach ($addresses as $address) {
Expand All @@ -129,8 +131,9 @@ public function acquire(SessionConfiguration $config): Generator
/** @var BoltConnection $connection */
$connection = GeneratorHelper::getReturnFromGenerator($pool->acquire($config));
$table = $this->routingTable($connection, $config);
} catch (Throwable) {
} catch (Throwable $e) {
// todo - once client side logging is implemented it must be conveyed here.
$latestError = $e;
continue; // We continue if something is wrong with the current server
}

Expand All @@ -142,7 +145,7 @@ public function acquire(SessionConfiguration $config): Generator
}

if ($table === null) {
throw new RuntimeException(sprintf('Cannot connect to host: "%s". Hosts tried: "%s"', $this->data->getUri()->getHost(), implode('", "', $triedAddresses)));
throw new RuntimeException(sprintf('Cannot connect to host: "%s". Hosts tried: "%s"', $this->data->getUri()->getHost(), implode('", "', $triedAddresses)), previous: $latestError);
}

$server = $this->getNextServer($table, $config->getAccessMode()) ?? $this->data->getUri();
Expand Down

0 comments on commit 543cc52

Please sign in to comment.