Skip to main content

lash/
error.rs

1use crate::support::*;
2
3#[derive(Debug, thiserror::Error)]
4pub enum EmbedError {
5    #[error(
6        "protocol plugin is required; call .protocol_plugin(...) or use StandardCore::builder()/RlmCore::builder()"
7    )]
8    MissingProtocolPlugin,
9    #[error("model spec is required; hosts must supply explicit model metadata")]
10    MissingModelSpec,
11    #[error("effect host is required; provide an explicit effect host with .effect_host(...)")]
12    MissingEffectHost,
13    #[error(
14        "lashlang artifact store is required; provide an explicit Lashlang artifact store with .lashlang_artifact_store(...)"
15    )]
16    MissingLashlangArtifactStore,
17    #[error(
18        "attachment store is required; provide an explicit attachment store with .attachment_store(...)"
19    )]
20    MissingAttachmentStore,
21    #[error(
22        "process execution environment store is required; provide an explicit process env store with .process_env_store(...)"
23    )]
24    MissingProcessEnvStore,
25    #[error("failed to create store for session `{session_id}`: {message}")]
26    StoreFactory { session_id: String, message: String },
27    #[error("store is bound to session `{loaded}` but builder requested `{requested}`")]
28    StoreSessionMismatch { loaded: String, requested: String },
29    #[error("durable process worker requires a LashCore store factory")]
30    MissingProcessWorkerStoreFactory,
31    #[error(
32        "durable session store requires a durable {facet}; an ephemeral {facet} cannot back a durable session store"
33    )]
34    DurableStorePeerRequired { facet: &'static str },
35    #[error(
36        "durable process registry requires a durable session store factory; call .store_factory(...) with a durable store"
37    )]
38    DurableProcessRegistryRequiresStoreFactory,
39    #[error(
40        "a process registry is configured for the default inline process work runner but no session store factory is wired; the runner rebuilds a session runtime per process and cannot do so without one. Wire .store_factory(...) - InMemorySessionStoreFactory::new() for ephemeral process execution, or a durable factory - or use .process_work_driver(...) for an externally driven durable runner."
41    )]
42    ProcessRegistryRequiresStoreFactory,
43    #[error("durable process worker config requires a LashCore process registry")]
44    MissingProcessRegistry,
45    #[error("session deletion requires a LashCore store factory")]
46    MissingSessionStoreFactory,
47    #[error("failed to delete process state for session `{session_id}`: {message}")]
48    SessionDeleteProcess { session_id: String, message: String },
49    #[error("missing required turn input for plugin `{plugin_id}`")]
50    MissingPluginTurnInput { plugin_id: &'static str },
51    #[error(
52        "configured effect host for {operation} is durable and requires a handler context; use .effects(&controller) and provide .turn_id(...) for replayable foreground requests"
53    )]
54    DurableEffectHostRequiresHandlerContext { operation: &'static str },
55    #[error(
56        "pull-style turn streams require an effect host that can create a static scoped controller; use stream_to(...) inside the handler context"
57    )]
58    StaticTurnStreamRequiresStaticEffectHost,
59    #[error("runtime session error: {0}")]
60    Session(#[from] SessionError),
61    #[error("runtime turn error: {0}")]
62    Runtime(#[from] lash_core::RuntimeError),
63    #[error("runtime plugin/control error: {0}")]
64    Plugin(#[from] lash_core::PluginError),
65    #[error("failed to encode protocol turn options: {0}")]
66    ProtocolTurnOptions(#[from] serde_json::Error),
67    #[error("runtime control unavailable: {0}")]
68    Control(#[from] lash_core::PluginActionInvokeError),
69}
70
71pub type Result<T> = std::result::Result<T, EmbedError>;