Table of Contents

YamlFormatException Class

Definition

Namespace
Bodu.Text.Yaml
Assembly
Bodu.Text.Yaml.dll
Package
Bodu.Text.Yaml 1.0.0
Source
YamlFormatException.cs

Represents an error that occurs when YAML data is malformed or violates the YAML specification.

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

Remarks

Raised by the YAML reader - and therefore surfaced by YamlSerializer while deserializing - when the source text cannot be interpreted as a valid YAML stream: for example, inconsistent indentation, a tab used for indentation, an unterminated quoted scalar, an invalid escape sequence, a duplicate mapping key, or an alias that refers to no anchor. The error is signalled through the FormatException hierarchy so callers can catch it alongside other parse failures.

Because YAML 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

YamlFormatException()

Initializes a new instance of the YamlFormatException class.

public YamlFormatException()

YamlFormatException(string)

Initializes a new instance of the YamlFormatException class.

public YamlFormatException(string message)

Parameters

message string

The error message.

YamlFormatException(string, Exception)

Initializes a new instance of the YamlFormatException class.

public YamlFormatException(string message, Exception innerException)

Parameters

message string

The error message.

innerException Exception

The inner exception.

YamlFormatException(string, int, int, int)

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

public YamlFormatException(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