private void csvReader_ParseError(object sender, ParseErrorEventArgs e)
        {
            // skip over incomplete data rows, but let all other exceptions bubble up
            if (e.Error is MissingFieldCsvException)
            {
                _logger.Warn(string.Format("Skipping recordIndex={0} because of missing expected field at index {1}",
                    e.Error.CurrentRecordIndex, e.Error.CurrentFieldIndex));
                e.Action = ParseErrorAction.AdvanceToNextLine;
            }
            else
            {
                string msg = string.Format("Unrecoverable parsing problem encountered at filePosition={0} (recordIndex={0}, fieldIndex={1})",
                    e.Error.CurrentPosition, e.Error.CurrentRecordIndex, e.Error.CurrentFieldIndex);
                _logger.ErrorException(msg, e.Error);

                throw new CsvParsingException(msg, e.Error) { FilePosition = e.Error.CurrentPosition };
            }
        }
Пример #2
0
 void csv_ParseError(object sender, ParseErrorEventArgs e)
 {
     // if the error is that a field is missing, then skip to next line
     if (e.Error is MissingFieldException)
     {
         Logger.Error("--MISSING FIELD ERROR OCCURRED");
         e.Action = ParseErrorAction.AdvanceToNextLine;
     }
 }
Пример #3
0
 private void ParseError(object sender, ParseErrorEventArgs e)
 {
     // if the error is that a field is missing, then skip to next line
     if (e.Error is MissingFieldCsvException)
     {
         GeneralStatisticsMapper.Instance.Increment("Bol: MISSING FIELD ERROR OCCURRED");
         e.Action = ParseErrorAction.AdvanceToNextLine;
     }
     else if (e.Error is MalformedCsvException)
     {
         GeneralStatisticsMapper.Instance.Increment("Bol: MALFORMED CSV ERROR OCCURRED");
         e.Action = ParseErrorAction.AdvanceToNextLine;
     }
     else
     {
         GeneralStatisticsMapper.Instance.Increment("Bol: PARSE ERROR OCCURRED");
         e.Action = ParseErrorAction.AdvanceToNextLine;
     }
 }
Пример #4
0
 static void csv_ParseError(object sender, ParseErrorEventArgs e)
 {
     MessageBox.Show(e.Error.Message, "Reader Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
 }