DotEnvFormatException Class
Definition
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
messagestringThe error message.
DotEnvFormatException(string, Exception)
Initializes a new instance of the DotEnvFormatException class.
public DotEnvFormatException(string message, Exception innerException)
Parameters
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
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
LineNumber
Gets the 1-based line number at which the parse error was detected, when available.
public int? LineNumber { get; }
Property Value
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
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
| Product | Versions |
|---|---|
| .NET | 8, 10 |