From 3e9edcd8afe7bf1b2fb7a076ee1f52d52ae543fb Mon Sep 17 00:00:00 2001 From: TekH Date: Thu, 27 Nov 2025 09:15:36 +0100 Subject: [PATCH] Add error handling and logging to Rec action invocation Enhanced the `InvokeRecActionCommandHandler` class by adding a `catch` block to handle exceptions during HTTP request and response processing. Logged exception details, including `ProfileId` and `ActionId`, using `logger?.LogError` for better observability. Ensured the `finally` block releasing the semaphore remains unaffected. --- .../RecActions/Commands/InvokeRecActionCommand.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs b/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs index f7d95da..6d7acd6 100644 --- a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs +++ b/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs @@ -46,6 +46,15 @@ public class InvokeRecActionCommandHandler(ISender sender, IHttpClientFactory cl var body = await response.Content.ReadAsStringAsync(cancel); var headers = response.Headers.ToDictionary(); } + catch(Exception ex) + { + logger?.LogError( + ex, + "Error invoking Rec action. ProfileId: {ProfileId}, ActionId: {ActionId}", + action.ProfileId, + action.ActionId + ); + } finally { semaphore.Release();