Table of Contents

Enum SofabError

Namespace
sofab
Assembly
SofaBuffers.dll

Error categories raised by the encoder and decoder.

public enum SofabError

Fields

Argument = 0

Invalid caller argument (e.g. a field id outside 0..ID_MAX).

BufferFull = 1

The output buffer is full and no flush sink is available.

InvalidMessage = 2

The input bytes are not a valid Sofab message (varint overflow, a reserved fixlen subtype, a count above ARRAY_MAX, nesting past MAX_DEPTH, dangling sequence end, ...).

A zero-count array is not in that company: it is a normal encoding — [ header ][ count=0 ] with no elements (CORELIB_PLAN §4.7), plus the fixlen_word naming the element subtype for a fixlen array (§4.8) — and decodes into a single ArrayBegin(int, ArrayKind, int) with a count of 0.

LimitExceeded = 3

A receiver-configured decode limit was exceeded for an unbounded (schema declares no count / maxlen) field — the wire count or total length reported by the decoder callbacks (array_begin, string, blob) is above a max_dyn_array_count / max_dyn_string_len / max_dyn_blob_len cap baked into the generated code.

This is policy, not wire malformation: the message is well-formed, but a receiver has chosen a stricter ceiling than the wire allows. It is therefore a category distinct from InvalidMessage — two backends with different configured caps must not read as wire-conformance divergence. A limit violation is always a hard decode error: the generated code raises it before allocating, and never clamps or truncates.

This corelib holds no limit — no field, no default, no fallback constant, and no omitted argument read as "unlimited" (CORELIB_PLAN §6.2.1). The values are generated code's throughout. What it does is perform the comparison where §6.2.1 wants it, for the two payload kinds whose length it already sees: String(int, int, byte[], int, int, long) and Blob(int, int, byte[], int, int, long) take the cap as a required argument and check total at the length header, before a byte is taken. An array element index is compared here too: PlaceElem<T>(List<T>, int, T, T, long, long), ReserveElem<T>(List<T>, int, Func<T>, long, long), ReserveRow<T>(List<List<T>>, int, long, long) and CheckIndex(int, long, long) take the schema count and the receiver cap and apply exactly one of them before the list grows. Only a native array's element count, announced at ArrayBegin(int, ArrayKind, int), has no such call and is compared in generated code — per §6.2.1's "one implementation, wherever it runs", each rule is enforced in exactly one of the two places.

A cap that was never stated is a caller defect, reported as Argument: LimitExceeded would promise a limit to raise that nobody configured. A format ceiling (ARRAY_MAX, FIXLEN_MAX) is the format's bound, not a receiver cap, and reaching one stays InvalidMessage. Mirrors the Go port's ErrLimitExceeded sentinel.

Remarks

Mirrors the C sofab_ret_t status codes (minus OK, which the C# API models as a normal return). Every SofabException carries one of these so callers can branch on the cause without string matching.