public sealed class CsvFormatException : FormatException
Namespace
CsvHelper
Assembly
CsvHelper.dll
Inheritance
object Exception SystemException FormatException CsvFormatException
Builds
net10.0 netstandard2.1 netstandard2.0 net47

Constructors

CsvFormatException(string)

Added in v34.0.0
public CsvFormatException(string message)

Creates an exception that is not tied to a position in the input.

Parameters

messagestring
The message that describes the problem.

View source

public CsvFormatException(string message, long recordNumber, long byteOffset)

Creates an exception for a problem at a known record and byte offset.

Parameters

messagestring
The message that describes the problem.
recordNumberlong
The 1-based number of the record (header included) where the problem was found.
byteOffsetlong
The offset, in bytes of UTF-8 input, near where the problem was found.

View source

public CsvFormatException(string message, long recordNumber, long byteOffset, Exception? innerException)

Creates an exception for a record that could not be read, caused by innerException.

Parameters

messagestring
The message that describes the problem.
recordNumberlong
The 1-based number of the record (header included).
byteOffsetlong
The offset, in bytes of UTF-8 input, where the record starts.
innerExceptionException?
The exception that the field or member threw.

View source

Properties

ByteOffset

Added in v34.0.0
public long ByteOffset { get; }

The offset, in bytes of UTF-8 input, near where the problem was found, or 0 when it is not known.

Property value

long

View source

FieldIndex

Added in v34.0.0
public int FieldIndex { get; init; }

The 0-based index of the field that Member reads, or -1 when it is not known (malformed input, no member, or a member that reads several fields, such as a nested record).

Property value

int

View source

Member

Added in v34.0.0
public string? Member { get; init; }

For a record that could not be read as its CsvRecordAttribute type, the member whose field could not be read, as error messages name it (Order.Price); null for malformed input, and when no member was at fault on its own (a constructor or a setter threw).

Property value

string?

View source

RecordNumber

Added in v34.0.0
public long RecordNumber { get; }

The 1-based number of the record where the problem was found, counting the header and the records returned before it (not skipped records, empty lines or comments); 0 when the problem is not tied to a record.

Property value

long

View source