mirror of
https://github.com/Govor-team/Govor.git
synced 2026-09-17 16:22:49 +00:00
3ec61fa2c0
was added removing messages many fixes bugs and moving to result pattern from throwing exceptions
16 lines
1.0 KiB
C#
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}";
|
|
} |