private static Exception ArgumentException(
            string paramName,
            object paramValue,
            OptsFn optsFn,
            string defaultMessage)
        {
            if (optsFn != null)
            {
                EnsureOptions ensureOptions = optsFn(new EnsureOptions());
                if (ensureOptions.CustomException != null)
                {
                    return(ensureOptions.CustomException);
                }

                if (ensureOptions.CustomMessage != null)
                {
                    return((Exception) new ArgumentOutOfRangeException(ensureOptions.CustomMessage, paramValue, paramName));
                }
            }

            return((Exception) new ArgumentOutOfRangeException(paramName, paramValue, defaultMessage));
        }
Ejemplo n.º 2
0
 private static EnsureOptions GenerateTypeErrorMessage(EnsureOptions options, string resourceType)
 {
     return(options.WithMessage($"Unknown resource type {resourceType}"));
 }