using System;

namespace FishDice.LuckyDice
{
    public sealed class InvalidLuckyDiceConfigException : Exception
    {
        public InvalidLuckyDiceConfigException(ConfigValidationResult validationResult)
            : base(BuildMessage(validationResult))
        {
            ValidationResult = validationResult;
        }

        public ConfigValidationResult ValidationResult { get; }

        private static string BuildMessage(ConfigValidationResult validationResult)
        {
            if (validationResult == null || validationResult.Errors.Count == 0)
            {
                return "Invalid Lucky Dice config.";
            }

            return "Invalid Lucky Dice config: " + validationResult.Errors[0].Code;
        }
    }
}
