From 0342b9e0c6eec5041add07e24a441717fedfdd88 Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 30 Mar 2026 11:55:58 +0200 Subject: [PATCH] Unify error status code as RecStatus.Failed Renamed RecStatus.QueryFailed to RecStatus.Failed and updated all usages and documentation to reflect its broader purpose as a general failure code for any operation, not just SQL queries. Improved consistency in error handling and status reporting across the codebase. --- .../Behaviors/InvokeAction/PostprocessingBehavior.cs | 2 +- .../Behaviors/InvokeAction/PreprocessingBehavior.cs | 2 +- .../RecActions/Commands/InvokeRecActionViewCommand.cs | 2 +- src/ReC.Domain/Constants/RecStatus.cs | 11 +++++------ src/ReC.Domain/Constants/RecStatusExtensions.cs | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/ReC.Application/Common/Behaviors/InvokeAction/PostprocessingBehavior.cs b/src/ReC.Application/Common/Behaviors/InvokeAction/PostprocessingBehavior.cs index 9fb3004..716d027 100644 --- a/src/ReC.Application/Common/Behaviors/InvokeAction/PostprocessingBehavior.cs +++ b/src/ReC.Application/Common/Behaviors/InvokeAction/PostprocessingBehavior.cs @@ -36,7 +36,7 @@ public class PostprocessingBehavior(IRecDbContext context, ISender sender) : IPi await sender.Send(new InsertResultCommand() { - Status = RecStatus.QueryFailed, + Status = RecStatus.Failed, ActionId = request.Action.Id, Error = error, Type = ResultType.Post diff --git a/src/ReC.Application/Common/Behaviors/InvokeAction/PreprocessingBehavior.cs b/src/ReC.Application/Common/Behaviors/InvokeAction/PreprocessingBehavior.cs index e5063c7..f7f16c7 100644 --- a/src/ReC.Application/Common/Behaviors/InvokeAction/PreprocessingBehavior.cs +++ b/src/ReC.Application/Common/Behaviors/InvokeAction/PreprocessingBehavior.cs @@ -31,7 +31,7 @@ public class PreprocessingBehavior(IRecDbContext context, ISender sender) : IPip { await sender.Send(new InsertResultCommand() { - Status = RecStatus.QueryFailed, + Status = RecStatus.Failed, ActionId = request.Action.Id, Error = ex.ToString(), Type = ResultType.Pre diff --git a/src/ReC.Application/RecActions/Commands/InvokeRecActionViewCommand.cs b/src/ReC.Application/RecActions/Commands/InvokeRecActionViewCommand.cs index a728e68..44afbdc 100644 --- a/src/ReC.Application/RecActions/Commands/InvokeRecActionViewCommand.cs +++ b/src/ReC.Application/RecActions/Commands/InvokeRecActionViewCommand.cs @@ -157,7 +157,7 @@ public class InvokeRecActionViewCommandHandler( { await sender.Send(new InsertResultCommand() { - Status = RecStatus.QueryFailed, + Status = RecStatus.Failed, ActionId = action.Id, Error = ex.ToString(), Type = ResultType.Main diff --git a/src/ReC.Domain/Constants/RecStatus.cs b/src/ReC.Domain/Constants/RecStatus.cs index 6d3fd07..5800139 100644 --- a/src/ReC.Domain/Constants/RecStatus.cs +++ b/src/ReC.Domain/Constants/RecStatus.cs @@ -6,8 +6,7 @@ namespace ReC.Domain.Constants; /// Represents status codes used to indicate the outcome of an operation. /// /// Includes all standard HTTP status codes as defined in , -/// as well as custom non-HTTP status codes for SQL query execution results -/// (e.g., and ). +/// as well as custom non-HTTP status codes for internal operation results. /// /// /// @@ -21,11 +20,11 @@ public enum RecStatus : short QuerySuccess = 0, /// - /// Indicates that a SQL query execution failed (value 999). - /// Used as the result status when - /// or throws an exception. + /// Indicates that an operation failed at any stage (value 999). + /// This includes SQL query failures during preprocessing/postprocessing, + /// HTTP request errors, or any other unhandled exception within the action pipeline. /// - QueryFailed = 999, + Failed = 999, // // Summary: diff --git a/src/ReC.Domain/Constants/RecStatusExtensions.cs b/src/ReC.Domain/Constants/RecStatusExtensions.cs index 154343d..e6ee54e 100644 --- a/src/ReC.Domain/Constants/RecStatusExtensions.cs +++ b/src/ReC.Domain/Constants/RecStatusExtensions.cs @@ -26,7 +26,7 @@ public static class RecStatusExtensions => status switch { RecStatus.QuerySuccess => true, - RecStatus.QueryFailed => false, + RecStatus.Failed => false, _ => status.ToHttpStatusCode() is HttpStatusCode httpStatus && httpStatus.IsSuccess() };