qualia_core_db/q42/chebi_query/
error.rs1use std::fmt;
4
5#[derive(Debug, Clone, PartialEq, Eq)]
7pub enum QueryError {
8 EmptyInput,
10 EmptyQuery,
12 NotFound,
14 Ambiguous { hits: usize },
16 LimitExceeded { limit: usize, needed: usize },
18 OutputFull { written: usize, capacity: usize },
20 InvalidLimits,
22 DepthExceeded { depth: usize, max: usize },
24}
25
26impl fmt::Display for QueryError {
27 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28 match self {
29 Self::EmptyInput => write!(f, "empty quin input"),
30 Self::EmptyQuery => write!(f, "empty or unnormalizable chemical query"),
31 Self::NotFound => write!(f, "chemical not found in asset slice"),
32 Self::Ambiguous { hits } => write!(f, "ambiguous chemical match (hits={hits})"),
33 Self::LimitExceeded { limit, needed } => {
34 write!(f, "query limit exceeded (limit={limit}, needed={needed})")
35 }
36 Self::OutputFull { written, capacity } => {
37 write!(f, "output full (written={written}, capacity={capacity})")
38 }
39 Self::InvalidLimits => write!(f, "query limits must be positive"),
40 Self::DepthExceeded { depth, max } => {
41 write!(f, "subgraph depth exceeded (depth={depth}, max={max})")
42 }
43 }
44 }
45}
46
47impl std::error::Error for QueryError {}