Skip to content

Commit 543cc52

Browse files
committed
explicitly passed previous exception during fetching of routing table
1 parent d7b48f0 commit 543cc52

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Neo4j/Neo4jConnectionPool.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ public function acquire(SessionConfiguration $config): Generator
120120
$table = $this->cache->get($key, null);
121121
$triedAddresses = [];
122122

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

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

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

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

0 commit comments

Comments
 (0)