From 653f6f8641194df50713cfb73bc72511b37997ac Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 18 Oct 2024 04:58:31 +0800 Subject: [PATCH] log webhook dispatch exception --- composer.json | 2 +- src/Listeners/SendResourceLifecycleWebhook.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 6077ba8..aa28a1a 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/src/Listeners/SendResourceLifecycleWebhook.php b/src/Listeners/SendResourceLifecycleWebhook.php index 3e9ef1f..9ee5863 100644 --- a/src/Listeners/SendResourceLifecycleWebhook.php +++ b/src/Listeners/SendResourceLifecycleWebhook.php @@ -104,11 +104,14 @@ 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, @@ -116,7 +119,7 @@ public function handle($event) '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,