klauthed_testing/
error.rs1use klauthed_macros::DomainError;
4
5#[derive(Debug, DomainError)]
12#[domain(prefix = "testing", category = "internal")]
13#[non_exhaustive]
14pub enum TestingError {
15 Fixture(String),
17}
18
19impl std::fmt::Display for TestingError {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 match self {
22 TestingError::Fixture(msg) => write!(f, "failed to build fixture: {msg}"),
23 }
24 }
25}
26
27impl std::error::Error for TestingError {}
28
29#[cfg(test)]
30mod tests {
31 use super::*;
32 use klauthed_error::{DomainError, ErrorCategory};
33
34 #[test]
35 fn fixture_error_is_internal() {
36 let err = TestingError::Fixture("nope".into());
37 assert_eq!(err.category(), ErrorCategory::Internal);
38 assert_eq!(err.code().as_str(), "testing.fixture");
39 assert!(err.to_string().contains("nope"));
40 }
41}