mirror of
https://github.com/Govor-team/Govor.git
synced 2026-09-17 16:22:49 +00:00
3c785d5c89
Migrate codebase to use SmartRes Result<T, Error> (and Unit) across services and interfaces, replacing previous Result usage and updating many method signatures and implementations. Add ResultExtensions to convert SmartRes results to ASP.NET ActionResult and refactor AuthController to use functional Bind/Tap chains for registration/login flows. Upgrade projects to .NET 10 and bump related NuGet packages; add libs/SmartRes.dll and project references. Simplify DbContext registration to use Npgsql only with retry policies and enable detailed logging. Update Swagger/launch settings and other minor fixes (AutoMapper registration change, whitespace/exception handling, and removal of the Govor.ConsoleClient files).
16 lines
918 B
C#
16 lines
918 B
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 override string ToString() => $"{Code}: {Message}";
|
|
} |