1
0
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:
Jimmy Vo
2025-03-06 11:16:58 -05:00
committed by GitHub
parent 7281dd9b58
commit c82908f40b
5 changed files with 224 additions and 1 deletions

View File

@@ -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 })
{
}
}