Refactor InsertObjectFailedException for more context
InsertObjectFailedException now requires an InsertObjectProcedure instance, improving error context. Exception throwing in InsertObjectProcedureHandler updated to pass the procedure object instead of just a message and serialized request.
This commit is contained in:
@@ -1,16 +1,23 @@
|
|||||||
|
using ReC.Application.Common.Procedures.InsertProcedure;
|
||||||
|
|
||||||
namespace ReC.Application.Common.Exceptions;
|
namespace ReC.Application.Common.Exceptions;
|
||||||
|
|
||||||
public class InsertObjectFailedException : Exception
|
public class InsertObjectFailedException : Exception
|
||||||
{
|
{
|
||||||
public InsertObjectFailedException() : base()
|
private readonly InsertObjectProcedure _procedure;
|
||||||
|
|
||||||
|
public InsertObjectFailedException(InsertObjectProcedure procedure) : base()
|
||||||
{
|
{
|
||||||
|
_procedure = procedure;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InsertObjectFailedException(string? message) : base(message)
|
public InsertObjectFailedException(InsertObjectProcedure procedure, string? message) : base(message)
|
||||||
{
|
{
|
||||||
|
_procedure = procedure;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InsertObjectFailedException(string? message, Exception? innerException) : base(message, innerException)
|
public InsertObjectFailedException(InsertObjectProcedure procedure, string? message, Exception? innerException) : base(message, innerException)
|
||||||
{
|
{
|
||||||
|
_procedure = procedure;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,8 +113,6 @@ public class InsertObjectProcedureHandler(IRepository repo) : IRequestHandler<In
|
|||||||
else if (long.TryParse(guidParam.Value.ToString(), out var guid))
|
else if (long.TryParse(guidParam.Value.ToString(), out var guid))
|
||||||
return guid;
|
return guid;
|
||||||
|
|
||||||
throw new InsertObjectFailedException(
|
throw new InsertObjectFailedException(request, "InsertObject stored procedure did not return a valid identifier.");
|
||||||
"InsertObject stored procedure did not return a valid identifier." +
|
|
||||||
JsonSerializer.Serialize(request, options: new() { WriteIndented = true }));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user