Table of Contents

DotEnvFormatException Class

Definition

Namespace
Bodu.Text.DotEnv
Assembly
Bodu.Text.DotEnv.dll
Package
Bodu.Text.DotEnv 1.0.0
Source
DotEnvFormatException.cs

Represents an error that occurs when DotEnv data is malformed.

public sealed class DotEnvFormatException : FormatException, ISerializable
Inheritance
DotEnvFormatException
Implements
Inherited Members
Extension Methods

Remarks

Raised by the DotEnv reader - and therefore surfaced by DotEnvSerializer while deserializing - when the source text cannot be interpreted as a valid DotEnv document: for example, an invalid key name, a missing assignment, or an unterminated quoted value. The error is signalled through the FormatException hierarchy so callers can catch it alongside other parse failures.

Because DotEnv is a line-oriented format, the exception records its position as a LineNumber and ColumnNumber in addition to the absolute byte Offset. Each is null when the error is not associated with a specific location.

Constructors

DotEnvFormatException()

Initializes a new instance of the DotEnvFormatException class.

public DotEnvFormatException()

DotEnvFormatException(string)

Initializes a new instance of the DotEnvFormatException class.

public DotEnvFormatException(string message)

Parameters

message string

The error message.

DotEnvFormatException(string, Exception)

Initializes a new instance of the DotEnvFormatException class.

public DotEnvFormatException(string message, Exception innerException)

Parameters

message string

The error message.

innerException Exception

The inner exception.

DotEnvFormatException(string, int, int, int)

Initializes a new instance of the DotEnvFormatException class and records the source location at which the parse error was detected.

public DotEnvFormatException(string message, int line, int column, int offset)

Parameters

message string

The error message.

line int

The 1-based line number at which the error occurred.

column int

The 1-based column number within the line at which the error occurred.

offset int

The zero-based byte offset from the start of the source.

Properties

ColumnNumber

Gets the 1-based column number within the line at which the parse error was detected, when available.

public int? ColumnNumber { get; }

Property Value

int?

The column number, or null when no column is associated with the error.

LineNumber

Gets the 1-based line number at which the parse error was detected, when available.

public int? LineNumber { get; }

Property Value

int?

The line number, or null when no line is associated with the error.

Offset

Gets the zero-based byte offset from the start of the UTF-8 source at which the parse error was detected, when available.

public int? Offset { get; }

Property Value

int?

The byte offset, or null when no position is associated with the error.

Remarks

The offset and ColumnNumber count UTF-8 bytes of the source document, not decoded characters; for ASCII-only documents the two coincide.

Applies to

ProductVersions
.NET8, 10