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:
parent
dcc0e8c806
commit
3e9edcd8af
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user