Skip to content
This repository was archived by the owner on Jun 10, 2022. It is now read-only.

Commit a8f5b01

Browse files
authored
Merge pull request #196 from simPod/connection-exception
Connection Exception
2 parents 622067f + 75409aa commit a8f5b01

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

src/Consumer/Process.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,7 @@ protected function syncMeta(): void
231231
return;
232232
}
233233

234-
throw new Exception(
235-
sprintf('It was not possible to establish a connection for metadata with the brokers "%s"', $brokerList)
236-
);
234+
throw Exception\ConnectionException::fromBrokerList($brokerList);
237235
}
238236

239237
protected function getGroupBrokerId(): void
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Kafka\Exception;
5+
6+
use Kafka\Exception;
7+
use function sprintf;
8+
9+
final class ConnectionException extends Exception
10+
{
11+
public static function fromBrokerList(string $brokerList): self
12+
{
13+
return new self(
14+
sprintf(
15+
'It was not possible to establish a connection for metadata with the brokers "%s"',
16+
$brokerList
17+
)
18+
);
19+
}
20+
}

src/Producer/Process.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,7 @@ public function syncMeta(): void
167167
}
168168
}
169169

170-
throw new Exception(
171-
sprintf(
172-
'It was not possible to establish a connection for metadata with the brokers "%s"',
173-
$brokerList
174-
)
175-
);
170+
throw Exception\ConnectionException::fromBrokerList($brokerList);
176171
}
177172

178173
/**

src/Producer/SyncProcess.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use function explode;
1515
use function json_encode;
1616
use function shuffle;
17-
use function sprintf;
1817
use function substr;
1918
use function trim;
2019

@@ -144,12 +143,7 @@ public function syncMeta(): void
144143
return;
145144
}
146145

147-
throw new Exception(
148-
sprintf(
149-
'It was not possible to establish a connection for metadata with the brokers "%s"',
150-
$brokerList
151-
)
152-
);
146+
throw Exception\ConnectionException::fromBrokerList($brokerList);
153147
}
154148

155149
/**

0 commit comments

Comments
 (0)