Skip to main content

difflore_core/domain/
mod.rs

1pub mod files;
2pub mod glob_match;
3pub mod models;
4pub mod origins;
5pub mod projects;
6pub mod providers;
7pub mod rule_view;
8pub mod settings;
9
10use thiserror::Error;
11
12#[derive(Error, Debug)]
13pub enum CoreError {
14    #[error("Database error: {0}")]
15    Database(#[from] sqlx::Error),
16    #[error("IO error: {0}")]
17    Io(#[from] std::io::Error),
18    #[error("JSON error: {0}")]
19    Json(#[from] serde_json::Error),
20    #[error("Validation error: {0}")]
21    Validation(String),
22    #[error("Not found: {0}")]
23    NotFound(String),
24    #[error("Internal error: {0}")]
25    Internal(String),
26    #[error("API error: {0}")]
27    Api(#[from] openapi_contract::ApiError),
28    // Cloud-managed embedding cap hit. Free tier reaches its rule cap;
29    // callers fall back to lexical retrieval for the offending embed call
30    // so recall keeps functioning. `cap` is the user's tier ceiling (e.g.
31    // 200); `used` is the current count from the cloud's response.
32    #[error("Embedding cap reached: {used}/{cap}")]
33    EmbedCapReached { cap: u32, used: u32 },
34}
35
36pub type Result<T> = std::result::Result<T, CoreError>;
37
38// Backwards-compatible re-export so `crate::errors::*` paths keep working.
39pub mod errors {
40    pub use super::{CoreError, Result};
41}