- Cleaned up whitespace in Directory.Build.props and Directory.Packages.props for consistency. - Reformatted project file references in PnvPanel.Api.csproj for better clarity. - Enhanced code readability in various endpoint files by adjusting line breaks and indentation. - Standardized method signatures and improved formatting in ResultExtensions and multiple endpoint classes for better maintainability.
35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
namespace PnvPanel.Application.Common.Models;
|
|
|
|
public enum ErrorType
|
|
{
|
|
Failure,
|
|
Validation,
|
|
NotFound,
|
|
Conflict,
|
|
Unauthorized,
|
|
Forbidden,
|
|
}
|
|
|
|
public sealed record Error(string Code, string Message, ErrorType Type = ErrorType.Failure)
|
|
{
|
|
public static readonly Error None = new(string.Empty, string.Empty);
|
|
|
|
public static Error Validation(string code, string message) =>
|
|
new(code, message, ErrorType.Validation);
|
|
|
|
public static Error NotFound(string code, string message) =>
|
|
new(code, message, ErrorType.NotFound);
|
|
|
|
public static Error Conflict(string code, string message) =>
|
|
new(code, message, ErrorType.Conflict);
|
|
|
|
public static Error Unauthorized(string code, string message) =>
|
|
new(code, message, ErrorType.Unauthorized);
|
|
|
|
public static Error Forbidden(string code, string message) =>
|
|
new(code, message, ErrorType.Forbidden);
|
|
|
|
public static Error Failure(string code, string message) =>
|
|
new(code, message, ErrorType.Failure);
|
|
}
|