Skip to main content

openmetadata_rs_sdk/
errors.rs

1/// Error categories for OpenMetadata SDK.
2#[derive(Debug, thiserror::Error)]
3pub enum OpenMetadataError {
4    /// HTTP related error
5    #[error("HTTP error: {0}")]
6    Http(String),
7    /// Serialization related error
8    #[error("Serialization error: {0}")]
9    Serialization(String),
10    /// Error for if the entity is not found
11    #[error("Entity not found: {0}")]
12    NotFound(String),
13}
14
15#[cfg(test)]
16mod tests {
17    use super::*;
18
19    #[test]
20    fn check_errors() {
21        let e = OpenMetadataError::NotFound("test".to_string());
22        assert_eq!(e.to_string(), "Entity not found: test");
23
24        let e = OpenMetadataError::Http("Invalid URL".to_string());
25        assert_eq!(e.to_string(), "HTTP error: Invalid URL");
26
27        let e = OpenMetadataError::Serialization("Serialization error".to_string());
28        assert_eq!(e.to_string(), "Serialization error: Serialization error");
29    }
30}