Skip to content

Commit

Permalink
log webhook dispatch exception
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Oct 17, 2024
1 parent e5bc18f commit 653f6f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fleetbase/core-api",
"version": "1.5.16",
"version": "1.5.17",
"description": "Core Framework and Resources for Fleetbase API",
"keywords": [
"fleetbase",
Expand Down
7 changes: 5 additions & 2 deletions src/Listeners/SendResourceLifecycleWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,22 @@ public function handle($event)
->payload($event->data)
->useSecret($apiSecret)
->dispatch();
} catch (\Aws\Sqs\Exception\SqsException $exception) {
} catch (\Exception|\Aws\Sqs\Exception\SqsException $exception) {
// get webhook attempt request/response interfaces
$response = $exception->getResponse();
$request = $exception->getRequest();

// Log error
Log::error($exception->getMessage());

// Prepare log data
$webhookRequestLogData = [
'company_uuid' => $webhook->company_uuid,
'webhook_uuid' => $webhook->uuid,
'api_event_uuid' => $apiEvent->uuid,
'method' => $request->getMethod(),
'status_code' => $exception->getStatusCode(),
'reason_phrase' => $exception->getMessage() ?? $response->getReasonPhrase(),
'reason_phrase' => $response->getReasonPhrase() ?? $exception->getMessage(),
'duration' => $durationStart->diffInSeconds(now()),
'url' => $request->getUri(),
'attempt' => 1,
Expand Down

0 comments on commit 653f6f8

Please sign in to comment.