namespace PkmnLib.Static.Utils.Errors;

/// <summary>
/// A result that indicates an index is out of range.
/// </summary>
public class OutOfRangeException : Exception
{
    private readonly string _hint;
    private readonly int _index;
    private readonly int _max;

    /// <inheritdoc cref="OutOfRangeException"/>
    public OutOfRangeException(string hint, int index, int max)
    {
        _hint = hint;
        _index = index;
        _max = max;
    }

    /// <inheritdoc />
    public override string Message => _max == 0
        ? $"{_hint} index {_index} is out of range. Collection is empty."
        : $"{_hint} index {_index} is out of range. Must be between 0 and {_max - 1}.";
}