CQRS with MediatR, PipelineBehavior for handling exception happened in the Commands and Queries,Commands, most of Commands in this project are returning a result ( type ) inherited from CommandResult<TValue, TCommandResultclass, that class used to implement the Result Pattern, Command if executed successfully it should return a result ( its type inherited from CommandResult<TValue, TCommandResult) that represents a succeeded operation, but in an Exception situation the command should return a result ( its type inherited from CommandResult<TValue, TCommandResult) that represents a failed operation, and both Faild and Succeeededare the same type.PiplineBehavior, TResponse related to the request and create a Failed result then return iit.CreateFailedResult iit checks and returns the correct result, and the issue is that method checks all the commands and also queries, nd as you will notice that at this moment there are many ifs there, and in the future handreds of commands and queries will be added.