Files
Govor/Govor.Domain/Common/Error.cs
T
Artemy 3ec61fa2c0 Stable server
was added removing messages
many fixes bugs and moving to result pattern from throwing exceptions
2026-08-22 19:28:42 +07:00

16 lines
1.0 KiB
C#

namespace Govor.Domain.Common;
public record Error(string Code, string Message, ErrorType Type, Dictionary<string, string[]>? Errors = null)
{
public static Error NotFound(string code, string message) => new(code, message, ErrorType.NotFound);
public static Error Validation(string code, string message, Dictionary<string, string[]>? errors = null) =>
new(code, message, ErrorType.Validation, errors);
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);
public static Error ServerError(string code, string message) => new(code, message, ErrorType.ServerError);
public override string ToString() => $"{Code}: {Message}";
}