Improve error handling with DataIntegrityException
Introduce a new `DataIntegrityException` class to handle data integrity issues. Replace the logging and early return for `null` `RestType` in `InvokeRecActionCommandHandler` with throwing the new exception. This ensures explicit error handling and improves runtime issue detection.
This commit is contained in:
parent
a2ebbe83cb
commit
e62dfbcc7a
@ -0,0 +1,8 @@
|
||||
namespace ReC.Application.Common.Exceptions;
|
||||
|
||||
public class DataIntegrityException : Exception
|
||||
{
|
||||
public DataIntegrityException() { }
|
||||
|
||||
public DataIntegrityException(string message) : base(message) { }
|
||||
}
|
||||
@ -3,6 +3,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ReC.Application.Common;
|
||||
using ReC.Application.Common.Dto;
|
||||
using ReC.Application.Common.Exceptions;
|
||||
using ReC.Application.OutResults.Commands;
|
||||
using System.Text.Json;
|
||||
|
||||
@ -31,14 +32,11 @@ public class InvokeRecActionCommandHandler(
|
||||
using var http = clientFactory.CreateClient();
|
||||
|
||||
if (action.RestType is null)
|
||||
{
|
||||
logger?.LogWarning(
|
||||
"Rec action could not be invoked because the RestType value is null. ProfileId: {ProfileId}, Id: {Id}",
|
||||
action.ProfileId,
|
||||
action.Id
|
||||
);
|
||||
return;
|
||||
}
|
||||
throw new DataIntegrityException(
|
||||
$"Rec action could not be invoked because the RestType value is null. " +
|
||||
$"ProfileId: {action.ProfileId}, " +
|
||||
$"Id: {action.Id}"
|
||||
);
|
||||
|
||||
using var httpReq = action.RestType
|
||||
.ToHttpMethod()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user