Skip to main content

lash/
error.rs

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