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.
This commit is contained in:
tekh 2025-11-27 09:15:36 +01:00
parent dcc0e8c806
commit 3e9edcd8af

View File

@ -46,6 +46,15 @@ public class InvokeRecActionCommandHandler(ISender sender, IHttpClientFactory cl
var body = await response.Content.ReadAsStringAsync(cancel); var body = await response.Content.ReadAsStringAsync(cancel);
var headers = response.Headers.ToDictionary(); var headers = response.Headers.ToDictionary();
} }
catch(Exception ex)
{
logger?.LogError(
ex,
"Error invoking Rec action. ProfileId: {ProfileId}, ActionId: {ActionId}",
action.ProfileId,
action.ActionId
);
}
finally finally
{ {
semaphore.Release(); semaphore.Release();