public bool ReadingExceptionOccurred(CsvHelperException obj)
        {
            var line = new FlatFileLine(obj.ReadingContext);

            switch (_strategy)
            {
            case BadDataHandlingStrategy.IgnoreRows:
                if (_maximumErrorsToReport-- > 0)
                {
                    _listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Warning, "Ignored ReadingException on " + line.GetLineDescription(), obj));
                }

                //move to next line
                _dataPusher.BadLines.Add(obj.ReadingContext.RawRow);

                break;

            case BadDataHandlingStrategy.DivertRows:

                DivertErrorRow(new FlatFileLine(obj.ReadingContext), obj);
                break;

            case BadDataHandlingStrategy.ThrowException:
                throw new FlatFileLoadException("Bad data found on li" + line.GetLineDescription(), obj);

            default:
                throw new ArgumentOutOfRangeException();
            }

            //todo should this return true or false? not clear, this was an API change in CSV.
            return(true);
        }
        public static string GetFriendlyErrorMessage(this CsvHelperException exception)
        {
            if (exception is TypeConverterException tex)
            {
                return($"{tex.MemberMapData.Names[0]}: ${tex.GetDeepestMessage()}");
            }

            if (exception is FieldValidationException fvex)
            {
                var reader      = fvex.Context.Reader;
                var headerNames = new List <string>();
                for (var i = 0; i < reader.Parser.Record.Length; i++)
                {
                    if (reader.Parser[i] == fvex.Field)
                    {
                        headerNames.Add(reader.HeaderRecord[i]);
                    }
                }

                if (headerNames.Any())
                {
                    return($"Error converting: {string.Join(",", headerNames)} to typed value");
                }
            }

            return($"{exception.GetDeepestMessage()}");
        }
 /// <summary>
 /// Throws the given <paramref name="exception"/>.
 /// </summary>
 public static bool ReadingExceptionOccurred(CsvHelperException exception)
 {
     return(true);
 }
 /// <summary>
 /// Throws the given <paramref name="exception"/>.
 /// </summary>
 public static void ReadingExceptionOccurred(CsvHelperException exception)
 {
     throw exception;
 }