mirror of
https://github.com/bitwarden/server
synced 2025-12-13 23:03:36 +00:00
[PM-15621] Add functionality to map command results to HTTP responses. (#5467)
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
namespace Bit.Core.Models.Commands;
|
||||
#nullable enable
|
||||
|
||||
namespace Bit.Core.Models.Commands;
|
||||
|
||||
public class CommandResult(IEnumerable<string> errors)
|
||||
{
|
||||
@@ -10,3 +12,39 @@ public class CommandResult(IEnumerable<string> errors)
|
||||
|
||||
public CommandResult() : this(Array.Empty<string>()) { }
|
||||
}
|
||||
|
||||
public class Failure : CommandResult
|
||||
{
|
||||
protected Failure(IEnumerable<string> errorMessages) : base(errorMessages)
|
||||
{
|
||||
|
||||
}
|
||||
public Failure(string errorMessage) : base(errorMessage)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class Success : CommandResult
|
||||
{
|
||||
}
|
||||
|
||||
public abstract class CommandResult<T>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class Success<T>(T data) : CommandResult<T>
|
||||
{
|
||||
public T? Data { get; init; } = data;
|
||||
}
|
||||
|
||||
public class Failure<T>(IEnumerable<string> errorMessage) : CommandResult<T>
|
||||
{
|
||||
public IEnumerable<string> ErrorMessages { get; init; } = errorMessage;
|
||||
|
||||
public Failure(string errorMessage) : this(new[] { errorMessage })
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user