Table of Contents

BencodeSerializationException Class

Definition

Namespace
Bodu.Text.Bencode
Assembly
Bodu.Text.Bencode.dll
Package
Bodu.Text.Bencode 1.0.0
Source
BencodeSerializationException.cs

The exception thrown when a value cannot be bound to or from a Bencode document during serialization - for example a type mismatch, a missing required member, or a value Bencode cannot represent.

public sealed class BencodeSerializationException : Exception, ISerializable
Inheritance
BencodeSerializationException
Implements
Inherited Members
Extension Methods

Remarks

This exception reports a binding-level failure and is distinct from BencodeFormatException, which reports that the source bytes were not well-formed Bencode. When the failure can be traced to a position in the source bytes, BytesOffset carries it.

The two causes are deliberately kept distinct; catch both exception types when the handling should not distinguish malformed bytes from unmappable values.

Constructors

BencodeSerializationException()

Initializes a new instance of the BencodeSerializationException class.

public BencodeSerializationException()

BencodeSerializationException(string)

Initializes a new instance of the BencodeSerializationException class with the specified message.

public BencodeSerializationException(string message)

Parameters

message string

The message that describes the error.

BencodeSerializationException(string, Exception?)

Initializes a new instance of the BencodeSerializationException class with the specified message and a reference to the inner exception that caused it.

public BencodeSerializationException(string message, Exception? innerException)

Parameters

message string

The message that describes the error.

innerException Exception

The exception that caused the current exception.

BencodeSerializationException(string, int)

Initializes a new instance of the BencodeSerializationException class with the specified message and source byte offset.

public BencodeSerializationException(string message, int bytesOffset)

Parameters

message string

The message that describes the error.

bytesOffset int

The byte offset into the source at which the error was detected.

Properties

BytesOffset

Gets the byte offset into the source at which the error was detected, when available.

public int? BytesOffset { get; }

Property Value

int?

The byte offset, or null when the failure has no associated position.

Applies to

ProductVersions
.NET8, 10