Skip to main content

bamboo_engine/session_app/
errors.rs

1//! Error types for session use cases.
2
3/// Errors that can occur when loading a session.
4#[derive(Debug, thiserror::Error)]
5pub enum SessionLoadError {
6    #[error("session not found: {0}")]
7    NotFound(String),
8    #[error("storage error: {0}")]
9    StorageError(String),
10}
11
12/// Errors that can occur when saving a session.
13#[derive(Debug, thiserror::Error)]
14pub enum SessionSaveError {
15    #[error("storage error: {0}")]
16    StorageError(String),
17}
18
19/// Errors from the chat use case.
20#[derive(Debug, thiserror::Error)]
21pub enum ChatError {
22    #[error("session load failed: {0}")]
23    LoadFailed(#[from] SessionLoadError),
24    #[error("session save failed: {0}")]
25    SaveFailed(#[from] SessionSaveError),
26    #[error("invalid model: {0}")]
27    InvalidModel(String),
28    #[error("invalid workflow selection: {0}")]
29    InvalidWorkflowSelection(String),
30    #[error("invalid Root orchestration tool selection: {0}")]
31    RootToolAuthority(#[from] bamboo_domain::RootToolAuthorityError),
32    #[error("session carries an invalid Project identity '{raw}': {message}")]
33    InvalidProjectIdentity { raw: String, message: String },
34    #[error(
35        "session Project membership changed while preparing chat (expected {expected:?}, actual {actual:?})"
36    )]
37    ProjectIdentityConflict {
38        expected: Option<bamboo_domain::ProjectId>,
39        actual: Option<bamboo_domain::ProjectId>,
40    },
41}
42
43/// Errors from the execute preparation use case.
44#[derive(Debug, thiserror::Error)]
45pub enum ExecutePreparationError {
46    #[error("session not found: {0}")]
47    NotFound(String),
48    #[error("session load failed: {0}")]
49    LoadFailed(#[from] SessionLoadError),
50    #[error("session save failed: {0}")]
51    SaveFailed(#[from] SessionSaveError),
52    #[error("invalid model: model is required")]
53    ModelRequired,
54    #[error("invalid model reference: {0}")]
55    InvalidModelReference(String),
56    #[error("invalid image fallback configuration: {0}")]
57    ImageFallbackError(String),
58}
59
60/// Errors from the respond use case.
61#[derive(Debug, thiserror::Error)]
62pub enum RespondError {
63    #[error("session not found: {0}")]
64    NotFound(String),
65    #[error("session load failed: {0}")]
66    LoadFailed(#[from] SessionLoadError),
67    #[error("session save failed: {0}")]
68    SaveFailed(#[from] SessionSaveError),
69    #[error("no pending question waiting for response")]
70    NoPendingQuestion,
71    #[error("pending question changed (expected tool call {expected}, actual {actual})")]
72    PendingQuestionMismatch { expected: String, actual: String },
73    #[error("invalid response: {0}")]
74    InvalidResponse(String),
75}