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 Microsoft.Extensions.Logging;
|
||||||
using ReC.Application.Common;
|
using ReC.Application.Common;
|
||||||
using ReC.Application.Common.Dto;
|
using ReC.Application.Common.Dto;
|
||||||
|
using ReC.Application.Common.Exceptions;
|
||||||
using ReC.Application.OutResults.Commands;
|
using ReC.Application.OutResults.Commands;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
@ -31,14 +32,11 @@ public class InvokeRecActionCommandHandler(
|
|||||||
using var http = clientFactory.CreateClient();
|
using var http = clientFactory.CreateClient();
|
||||||
|
|
||||||
if (action.RestType is null)
|
if (action.RestType is null)
|
||||||
{
|
throw new DataIntegrityException(
|
||||||
logger?.LogWarning(
|
$"Rec action could not be invoked because the RestType value is null. " +
|
||||||
"Rec action could not be invoked because the RestType value is null. ProfileId: {ProfileId}, Id: {Id}",
|
$"ProfileId: {action.ProfileId}, " +
|
||||||
action.ProfileId,
|
$"Id: {action.Id}"
|
||||||
action.Id
|
|
||||||
);
|
);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
using var httpReq = action.RestType
|
using var httpReq = action.RestType
|
||||||
.ToHttpMethod()
|
.ToHttpMethod()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user