Table of Contents

Class CStructException

Namespace
CStructSharp.Diagnostics
Assembly
CStructSharp.dll

Base class for expected layout, path, binary-read, and binary-write failures reported by CStructSharp.

public abstract class CStructException : Exception, ISerializable
Inheritance
CStructException
Implements
Derived
Inherited Members

Constructors

CStructException(CStructErrorCode, string?, Exception?)

Creates one categorized failure and optionally retains its lower-level cause.

protected CStructException(CStructErrorCode code, string? message, Exception? innerException = null)

Parameters

code CStructErrorCode

The stable machine-readable failure category.

message string

The optional caller-facing diagnostic.

innerException Exception

The optional lower-level failure that caused this error.

Properties

Code

Gets the stable machine-readable failure category.

public CStructErrorCode Code { get; }

Property Value

CStructErrorCode

Member

Gets the name of the field being read or written when the failure surfaced, when known.

public string? Member { get; }

Property Value

string

MemberType

Gets the layout type of Member, when known.

public string? MemberType { get; }

Property Value

string

Message

Gets the diagnostic with every known fact appended: the field and its type, the requested path, and the position at which the operation stopped, so a caller that only logs the message still sees where the failure happened.

public override string Message { get; }

Property Value

string

Offset

Gets the position at which the operation stopped, when known: the absolute stream position for a stream operation, or the zero-based offset within the supplied region for a span, memory, or array operation. It is where the reader or writer was when the failure surfaced, which is at or after the item that failed, not necessarily its start.

public long? Offset { get; }

Property Value

long?

Path

Gets the normalized semantic path associated with the failure, when it is safe and known.

public string? Path { get; }

Property Value

string