namespace SharedKernel.Results;

public record Error
{
    public static readonly Error None = new(string.Empty, string.Empty, ErrorType.Failure);
    public static readonly Error NullValue = new("General.Null", "Null value was provided", ErrorType.Failure);

    public Error(string code, string description, ErrorType type)
    {
        Code = code;
        Description = description;
        Type = type;
    }

    public string Code { get; }
    public string Description { get; }
    public ErrorType Type { get; }

    public static Error Failure(string code, string description) {
        return new(code, description, ErrorType.Failure);
    }

    public static Error Unauthorized(string code, string description)
    {
        return new(code, description, ErrorType.Unauthorized);
    }

    public static Error NotFound(string code, string description)
    {
        return new(code, description, ErrorType.NotFound);
    }

    public static Error Forbidden(string code, string description)
    {
        return new(code, description, ErrorType.Forbidden);
    }

    public static Error Conflict(string code, string description)
    {
        return new(code, description, ErrorType.Conflict);
    }

    public static Error MethodNotAllowed(string code, string description)
    {
        return new(code, description, ErrorType.MethodNotAllowed);
    }

    public static Error Problem(string code, string description)
    {
        return new(code, description, ErrorType.Problem);
    }
}