Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions bundle/src/Comms/Comms.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public function send(
'X-Signature' => $this->signature($jsonPayload),
];

$failedPrefix = 'comms event ' . get_class($event) . ' to ' . $url . ' failed. ';

try {
$response = $this->httpClient->request(
'POST',
Expand All @@ -82,17 +84,13 @@ public function send(

return $response;
} catch (TransportExceptionInterface $e) { // @codeCoverageIgnoreStart
throw new CommsApiFailedException(
'comms event to ' . $url . ' failed. Connection error: ' . $e->getMessage(),
);
throw new CommsApiFailedException($failedPrefix . 'Connection error: ' . $e->getMessage());
} catch (DecodingExceptionInterface $e) {
throw new CommsApiFailedException(
'comms event to ' . $url . ' failed. Decoding error: ' . $e->getMessage(),
);
throw new CommsApiFailedException($failedPrefix . 'Decoding error: ' . $e->getMessage());
} catch (HttpExceptionInterface $e) {
throw new CommsApiFailedException(
'comms event to ' . $url . ' failed. Status code: ' . $response->getStatusCode() .
' - ' . substr($response->getContent(false), 0, 250)
$failedPrefix . 'Status code: ' . $e->getResponse()->getStatusCode() .
' - ' . substr($e->getResponse()->getContent(false), 0, 250)
);
}
// @codeCoverageIgnoreEnd
Expand Down
Loading