Skip to main content

mur_common/
error.rs

1//! Typed errors for MUR library boundaries.
2
3/// Errors from store operations (YAML, LanceDB).
4#[derive(Debug, thiserror::Error)]
5pub enum StoreError {
6    #[error("pattern not found: {0}")]
7    NotFound(String),
8    #[error("pattern already exists: {0}")]
9    AlreadyExists(String),
10    #[error("I/O error: {0}")]
11    Io(#[from] std::io::Error),
12    #[error("YAML serialization error: {0}")]
13    Yaml(#[from] serde_yaml::Error),
14    #[error("store error: {0}")]
15    Other(String),
16}
17
18/// Errors from retrieval/scoring operations.
19#[derive(Debug, thiserror::Error)]
20pub enum RetrieveError {
21    #[error("store error: {0}")]
22    Store(#[from] StoreError),
23    #[error("embedding error: {0}")]
24    Embedding(String),
25    #[error("retrieval error: {0}")]
26    Other(String),
27}
28
29/// Errors from injection operations.
30#[derive(Debug, thiserror::Error)]
31pub enum InjectError {
32    #[error("I/O error: {0}")]
33    Io(#[from] std::io::Error),
34    #[error("no patterns to inject")]
35    Empty,
36    #[error("injection error: {0}")]
37    Other(String),
38}
39
40/// Errors from LLM client operations.
41#[derive(Debug, thiserror::Error)]
42pub enum LlmError {
43    #[error("API request failed: {0}")]
44    Request(String),
45    #[error("invalid response: {0}")]
46    InvalidResponse(String),
47    #[error("provider not configured: {0}")]
48    NotConfigured(String),
49    #[error("LLM error: {0}")]
50    Other(String),
51}