Class: AstmSerializeError
Thrown by the record/frame emit side when a value cannot be serialized into a
spec-clean stream - specifically when a component contains a record terminator
(CR/LF), which the ASTM escape codec cannot encode and which would break
framing if emitted raw. Carries a stable code + positional context, never the
offending value (PHI discipline).
Example
import { serializeAstmRecord, AstmSerializeError, parseAstmRecords } from "@cosyte/astm";
const rec = parseAstmRecords("H|\\^&\rL|1\r").records[1]!;
try {
serializeAstmRecord(rec);
} catch (err) {
if (err instanceof AstmSerializeError) err.code; // "ASTM_EMIT_UNENCODABLE_VALUE"
}
Extends
Error
Constructors
Constructor
new AstmSerializeError(
message,recordIndex?,code?):AstmSerializeError
Internal
Parameters
message
string
recordIndex?
number
code?
AstmSerializeErrorCode = "ASTM_EMIT_UNENCODABLE_VALUE"
Returns
AstmSerializeError
Overrides
Error.constructor
Properties
code
readonlycode:AstmSerializeErrorCode
Stable discriminant. ASTM_EMIT_UNENCODABLE_VALUE for a CR/LF in a value;
ASTM_EMIT_INVALID_DELIMITERS for a delimiter set that cannot be emitted
reversibly.
recordIndex?
readonlyoptionalrecordIndex?:number
0-based ordinal of the record within the message, when known.