Skip to content

Commit

Permalink
Return early
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric committed Nov 29, 2023
1 parent afcfb37 commit 65088fb
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions src/Transport/HttpTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,28 +122,30 @@ public function close(?int $timeout = null): Result

private function sendRequestToSpotlight(Event $event): void
{
if ($this->options->isSpotlightEnabled()) {
$request = new Request();
$request->setStringBody($this->payloadSerializer->serialize($event));

try {
$spotLightResponse = SpotlightClient::sendRequest(
$request,
'http://localhost:8969/stream'
);
if (!$this->options->isSpotlightEnabled()) {
return;
}

$request = new Request();
$request->setStringBody($this->payloadSerializer->serialize($event));

if ($spotLightResponse->hasError()) {
$this->logger->info(
sprintf('Failed to send the event to Sentry. Reason: "%s".', $spotLightResponse->getError()),
['event' => $event]
);
}
} catch (\Throwable $exception) {
try {
$spotLightResponse = SpotlightClient::sendRequest(
$request,
'http://localhost:8969/stream'
);

if ($spotLightResponse->hasError()) {
$this->logger->info(
sprintf('Failed to send the event to Spotlight. Reason: "%s".', $exception->getMessage()),
['exception' => $exception, 'event' => $event]
sprintf('Failed to send the event to Spotlight. Reason: "%s".', $spotLightResponse->getError()),
['event' => $event]
);
}
} catch (\Throwable $exception) {
$this->logger->info(
sprintf('Failed to send the event to Spotlight. Reason: "%s".', $exception->getMessage()),
['exception' => $exception, 'event' => $event]
);
}
}
}

0 comments on commit 65088fb

Please sign in to comment.