liminal_sdk/error.rs
1use alloc::string::String;
2
3/// Error taxonomy returned by the Rust SDK API surface.
4///
5/// The SDK keeps application code independent from transport, protocol framing,
6/// and core implementation error types. Concrete embedded and remote adapters
7/// map their internal failures into these variants.
8///
9/// `Clone` is derived so a failure can be both RETAINED and RETURNED at the same
10/// seam. A store failure that bricks a participant handle is exactly that shape:
11/// the error travels to the caller of the failing operation, while a copy stays
12/// behind as the reason every later call reports
13/// `RemoteParticipantError::StateUnavailable`. Without it the cause is
14/// observable exactly once and only by whoever happened to make the failing
15/// call.
16#[derive(Clone, Debug, PartialEq, Eq, thiserror::Error)]
17pub enum SdkError {
18 /// Establishing, keeping, or recovering a client connection failed.
19 #[error("connection error: {description}")]
20 Connection {
21 /// Human-readable context from the failing connection operation.
22 description: String,
23 },
24
25 /// Encoding, decoding, or interpreting SDK-internal protocol state failed.
26 #[error("protocol error: {description}")]
27 Protocol {
28 /// Human-readable protocol failure context.
29 description: String,
30 },
31
32 /// Serialising an outbound value or deserialising an inbound value failed.
33 #[error("serialization error: {description}")]
34 Serialization {
35 /// Human-readable serialization failure context.
36 description: String,
37 },
38
39 /// A typed message did not satisfy the schema declared for its channel.
40 #[error("type validation failed: {description}")]
41 TypeValidation {
42 /// Human-readable type-validation context.
43 description: String,
44 },
45
46 /// A publish operation encountered application-visible backpressure.
47 #[error("backpressure: {reason}")]
48 Backpressure {
49 /// Human-readable pressure reason.
50 reason: String,
51 },
52
53 /// A conversation operation failed.
54 #[error("conversation {conversation_id}: {description}")]
55 Conversation {
56 /// Application-visible conversation identifier.
57 conversation_id: String,
58 /// Human-readable conversation failure context.
59 description: String,
60 },
61
62 /// Persisted subscription or recovery state could not be read or written.
63 #[error("store error: {description}")]
64 Store {
65 /// Human-readable store failure context.
66 description: String,
67 },
68}