Skip to main content

type_bridge_server/
error.rs

1#[derive(Debug, thiserror::Error)]
2pub enum PipelineError {
3    #[error("Configuration error: {0}")]
4    Config(String),
5    #[error("TypeDB connection error: {0}")]
6    Connection(String),
7    #[error("Query execution error: {0}")]
8    QueryExecution(String),
9    #[error("Validation error: {0}")]
10    Validation(String),
11    #[error("Parse error: {0}")]
12    Parse(String),
13    #[error("Schema error: {0}")]
14    Schema(String),
15    #[error("Interceptor error: {0}")]
16    Interceptor(String),
17    #[error("Internal error: {0}")]
18    Internal(String),
19}
20
21#[cfg(test)]
22#[cfg_attr(coverage_nightly, coverage(off))]
23mod tests {
24    use super::*;
25
26    #[test]
27    fn display_config_error() {
28        let e = PipelineError::Config("bad config".into());
29        assert_eq!(e.to_string(), "Configuration error: bad config");
30    }
31
32    #[test]
33    fn display_connection_error() {
34        let e = PipelineError::Connection("refused".into());
35        assert_eq!(e.to_string(), "TypeDB connection error: refused");
36    }
37
38    #[test]
39    fn display_query_execution_error() {
40        let e = PipelineError::QueryExecution("syntax error".into());
41        assert_eq!(e.to_string(), "Query execution error: syntax error");
42    }
43
44    #[test]
45    fn display_validation_error() {
46        let e = PipelineError::Validation("invalid type".into());
47        assert_eq!(e.to_string(), "Validation error: invalid type");
48    }
49
50    #[test]
51    fn display_parse_error() {
52        let e = PipelineError::Parse("unexpected token".into());
53        assert_eq!(e.to_string(), "Parse error: unexpected token");
54    }
55
56    #[test]
57    fn display_schema_error() {
58        let e = PipelineError::Schema("file not found".into());
59        assert_eq!(e.to_string(), "Schema error: file not found");
60    }
61
62    #[test]
63    fn display_interceptor_error() {
64        let e = PipelineError::Interceptor("access denied".into());
65        assert_eq!(e.to_string(), "Interceptor error: access denied");
66    }
67
68    #[test]
69    fn display_internal_error() {
70        let e = PipelineError::Internal("unexpected".into());
71        assert_eq!(e.to_string(), "Internal error: unexpected");
72    }
73
74    #[test]
75    fn debug_format() {
76        let e = PipelineError::Config("test".into());
77        let debug = format!("{:?}", e);
78        assert!(debug.contains("Config"));
79    }
80}