Documentation
¶
Overview ¶
Package bson declares the error codes and the sentinels of the BSON codec, internal/service/data/codec/bson — range 0.3.36.* (ADR 0021 service/data/codec/bson block).
The codes live in the core at the path that mirrors the package emitting them (ADR 0160 §2) and keep the values they were allocated with: the LL byte 3 records the layer that allocated the range, not the directory that declares it today (ADR 0160 §3). Nothing here encodes or decodes — the mechanism, and the constructors that attach a failure's detail, stay in the service package.
Package bson — the sentinel *errs.Error values, one per code. Each Reason derives from its var name or from its Code constant (ADR 0020); the Public and Private texts are the ones the service package always emitted, so moving the declaration changed no rendering.
Index ¶
Constants ¶
const CodeBSONDepthExceeded errs.Code = 0x00_03_24_04 // 0.3.36.4
CodeBSONDepthExceeded identifies a document or value nested deeper than maxBSONNestedLevels, in either direction (CWE-674 stack-exhaustion defence; on the encode side it is also what a cyclic value runs into).
const CodeBSONDuplicateKey errs.Code = 0x00_03_24_06 // 0.3.36.6
CodeBSONDuplicateKey identifies a document NewStrict's instance refused because one of its documents repeats an element name.
const CodeBSONMarshalFailed errs.Code = 0x00_03_24_01 // 0.3.36.1
CodeBSONMarshalFailed identifies a value Marshal or Append cannot encode: a top level that is not a document, a type BSON has no representation for, a string that is not UTF-8, a key holding a NUL, or an error a MarshalBSON method returned.
const CodeBSONSizeExceeded errs.Code = 0x00_03_24_03 // 0.3.36.3
CodeBSONSizeExceeded identifies an Unmarshal input whose length exceeds the 10 MiB hard cap (CWE-400 memory-exhaustion defence before any byte is read).
const CodeBSONUnknownMember errs.Code = 0x00_03_24_07 // 0.3.36.7
CodeBSONUnknownMember identifies a document NewStrict's instance refused because it carries an element no field of the target struct claims.
const CodeBSONUnmarshalFailed errs.Code = 0x00_03_24_02 // 0.3.36.2
CodeBSONUnmarshalFailed identifies input Unmarshal refuses: bytes that are not one well-formed BSON document, or a value the target cannot hold.
const CodeBSONValueInvalid errs.Code = 0x00_03_24_05 // 0.3.36.5
CodeBSONValueInvalid identifies a BSON value type that cannot be built from what it was given: a malformed ObjectID hex string, a decimal128 string that is not a number or not exactly representable, a JSON form of either that is neither of the shapes accepted.
Variables ¶
var ( // MarshalFailed marks a value Marshal or Append cannot encode. MarshalFailed = errs.Static(CodeBSONMarshalFailed, "BSON_MARSHAL_FAILED", "BSON encoding failed", "service/data/codec/bson: the value has no BSON encoding", 0, 0) // UnmarshalFailed marks input Unmarshal refuses. UnmarshalFailed = errs.Static(CodeBSONUnmarshalFailed, "BSON_UNMARSHAL_FAILED", "BSON decoding failed", "service/data/codec/bson: the input is not a well-formed BSON document the target can hold", 0, 0) // SizeExceeded marks an Unmarshal input over the 10 MiB hard cap. SizeExceeded = errs.Static(CodeBSONSizeExceeded, "SIZE_EXCEEDED", "BSON input exceeds size limit", "service/data/codec/bson: len(data) exceeds maxBSONBytes", 0, 0) // DepthExceeded marks a document or value nested deeper than the codec // reads or writes. DepthExceeded = errs.Static(CodeBSONDepthExceeded, "DEPTH_EXCEEDED", "BSON nesting depth exceeds limit", "service/data/codec/bson: nesting exceeds maxBSONNestedLevels", 0, 0) // ValueInvalid marks a BSON value type that cannot be built from its input. ValueInvalid = errs.Static(CodeBSONValueInvalid, "BSON_VALUE_INVALID", "BSON value is invalid", "service/data/codec/bson: the input does not describe a value of this BSON type", 0, 0) // DuplicateKey is the strict refusal of a document that repeats an element name. DuplicateKey = errs.Static(CodeBSONDuplicateKey, "DUPLICATE_KEY", "BSON document repeats an element name", "service/data/codec/bson: NewStrict refused a document holding two elements of one name", 0, 0) // UnknownMember is the strict refusal of an element no struct field claims. UnknownMember = errs.Static(CodeBSONUnknownMember, "UNKNOWN_MEMBER", "BSON document carries an unknown member", "service/data/codec/bson: NewStrict refused an element no field of the struct claims", 0, 0) )
Functions ¶
This section is empty.
Types ¶
This section is empty.