Skip to main content

Module error

Module error 

Source
Expand description

The public error taxonomy.

There is one variant per condition a caller can meaningfully react to, and nothing is stringly typed: a code the server supplied is kept as a number in a structured field so it can be matched on, never folded into a message [docs/spec/05-error-codes.md §1].

§No dependency’s error type is exposed

Every error this crate produces is one of its own, and every one of them is defined here — including TransportError, which the private transport port produces but does not own. A type that is part of the semver promise belongs to the module that makes it; leaving it in the port would have made an adapter’s internal decision a public commitment, and would have contradicted the promise that adding a transport is not a semver event (docs/adr/0007-transport-port-shape.md).

The single boxed cause is TransportError::Connect’s, which hides the underlying failure behind dyn std::error::Error — a box, not a named type, so no third-party crate’s semantic version becomes part of this crate’s. It is for reading, not for downcasting; see the type.

§No unreachable variant, either

Every variant of Error is one this crate can produce or one a caller can meaningfully build — see the note on the type. A variant that merely sounded plausible would be worse than a missing one: it invites a match arm that never runs and a recovery path that is never tested. The parser’s own failures are deliberately not among them. A line this client cannot read is never fatal and never a Result: it arrives as SessionEvent::Unrecognized, with the line intact, so that a server newer than this crate cannot break it.

§The two code catalogs

TLCP has exactly two catalogs of numeric codes, and they overlap: fourteen numbers appear in both with different meanings [docs/spec/05-error-codes.md §2]. Which catalog a code belongs to is therefore not something a caller can work out from the number, so this taxonomy encodes it in the variant:

VariantCatalogCarried by
Error::SessionAppendix A, Session Error CodesCONERR, END
Error::RequestAppendix B, Control Error CodesREQERR, ERROR, MSGFAIL

Matching on a code without knowing its catalog is a bug waiting to happen — code 20 means “session not found on a bind request” in one and “session not found” in the other, and code 48 means “maximum session duration reached” in one and “MPN device suspended” in the other.

Structs§

ServerError
A code and message exactly as the server supplied them.

Enums§

Error
Anything that can go wrong in a Lightstreamer client.
TransportError
Something went wrong moving bytes. Carries no protocol meaning.

Type Aliases§

Result
The result type returned throughout this crate.