Skip to content

Commit 3d0658c

Browse files
committed
Properly reject connection attempt if no connection manager matches
1 parent 5aeee75 commit 3d0658c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ConnectionManager/Extra/Multiple/ConnectionManagerSelective.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace ConnectionManager\Extra\Multiple;
44

55
use ConnectionManager\ConnectionManagerInterface;
6+
use React\Promise\When;
67
use \UnderflowException;
78
use \InvalidArgumentException;
89

@@ -14,7 +15,13 @@ class ConnectionManagerSelective implements ConnectionManagerInterface
1415

1516
public function getConnection($host, $port)
1617
{
17-
return $this->getConnectionManagerFor($host, $port)->getConnection($host, $port);
18+
try {
19+
$cm = $this->getConnectionManagerFor($host, $port);
20+
}
21+
catch (Exception $e) {
22+
return When::reject($e);
23+
}
24+
return $cm->getConnection($host, $port);
1825
}
1926

2027
public function addConnectionManagerFor($connectionManager, $targetHost=self::MATCH_ALL, $targetPort=self::MATCH_ALL, $priority=0)

0 commit comments

Comments
 (0)