Enum Class SofabError
- All Implemented Interfaces:
Serializable, Comparable<SofabError>, Constable
Mirrors the C sofab_ret_t status codes (minus OK, which the
Java API models as a normal return), plus LIMIT_EXCEEDED, a
receiver-side policy category that has no wire-format equivalent (analogous to
corelib-go's ErrLimitExceeded sentinel). Every SofabException
carries one of these so callers can branch on the cause without string matching.
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionInvalid caller argument (e.g. a field id outside0..ID_MAX).The output buffer is full and noFlushSinkis available.The input bytes are not a valid Sofab message (varint overflow, bad type tag, zero-length array, dangling sequence end, ...).A well-formed message field exceeds a receiver-configured decode limit for an unbounded (dynamic) field — one whose schema declares nocount/maxlen. -
Method Summary
Modifier and TypeMethodDescriptionstatic SofabErrorReturns the enum constant of this class with the specified name.static SofabError[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
ARGUMENT
Invalid caller argument (e.g. a field id outside0..ID_MAX). -
BUFFER_FULL
The output buffer is full and noFlushSinkis available. -
INVALID_MSG
The input bytes are not a valid Sofab message (varint overflow, bad type tag, zero-length array, dangling sequence end, ...).This is a statement about the wire bytes: they are malformed regardless of what follows or how the receiver is configured. It is deliberately distinct from
LIMIT_EXCEEDED, which is a policy decision about otherwise-well-formed bytes. -
LIMIT_EXCEEDED
A well-formed message field exceeds a receiver-configured decode limit for an unbounded (dynamic) field — one whose schema declares nocount/maxlen. The limits (max_dyn_array_count,max_dyn_string_len,max_dyn_blob_len) are configured in the sofabgen config and baked into generated code as constants (CORELIB_PLAN §6.2.1: "The numbers and the allocation are not the codec's").Where the comparison runs. §6.2.1 leaves that open — "A corelib MAY take a limit as an argument and perform the check itself" — and this library takes it on the calls generated code already makes at the length or index the limit guards:
PayloadAcc.string(int, int, byte[], int, int, Bound)/PayloadAcc.blob(int, int, byte[], int, int, Bound), and theSeqrow reservations. Each is raised throughSofab.limitExceeded(String). What has no such call — a native array count, the element index of a flat wrapper array — is still guarded by generated code on the count the visitor is handed (arrayBegin(id, kind, count),string/blob(id, total, offset, chunk)), before it allocates. Never both for one rule: §6.2.1 admits one implementation per check.Not wire malformation. Exceeding a receiver-configured limit is policy, not a property of the bytes: the same message is accepted by a backend with a higher (or no) limit. This category is therefore kept strictly distinct from
INVALID_MSGso that policy divergence between backends with different configured limits is not mistaken for a wire-conformance divergence (e.g. by the Crucible differential fuzzer).Always a hard error. A limit violation is never clamped and never truncated; it is raised before the allocation it prevents, and
IStream.feed(byte[], Visitor)latches it as it latchesINVALID_MSG— §6.3 makes it terminal too — but under this code: the exception a refused decode throws carriesLIMIT_EXCEEDED, neverINVALID_MSG, which is how §6.3's "MUST NOT be reported asInvalidMessage" is met. §6.3 offers two ways to surface it, "either a fourth decode outcome, or a terminal failure carrying theLimitExceededcode on the error channel"; this library takes the second, so there is no fourthDecodeStatusand no second place the refusal can be read.This corelib defines no limit and no default for one. It holds no
max_dyn_*value, supplies none to a caller who states none, and never presents a format ceiling (Sofab.ARRAY_MAX,Sofab.ID_MAX) as a receiver cap — breaching one of those isINVALID_MSG. A number it is handed is used for that one comparison and not retained (§6.2.1).
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-