adaptive_pipeline_domain/error.rs
1// /////////////////////////////////////////////////////////////////////////////
2// Adaptive Pipeline
3// Copyright (c) 2025 Michael Gardner, A Bit of Help, Inc.
4// SPDX-License-Identifier: BSD-3-Clause
5// See LICENSE file in the project root.
6// /////////////////////////////////////////////////////////////////////////////
7
8//! # Domain Error Module
9//!
10//! This module provides the comprehensive error types for the domain layer,
11//! implementing a structured error handling approach that categorizes all
12//! possible failure scenarios in the pipeline processing system.
13//!
14//! ## Overview
15//!
16//! The error module defines domain-specific errors that:
17//!
18//! - **Express Business Failures**: Errors that represent violations of
19//! business rules
20//! - **Maintain Type Safety**: Strongly-typed error variants for compile-time
21//! safety
22//! - **Provide Context**: Rich error information for debugging and user
23//! feedback
24//! - **Support Error Recovery**: Categorization enables appropriate recovery
25//! strategies
26//! - **Enable Error Translation**: Clean conversion to application and
27//! interface layer errors
28//!
29//! ## Error Categories
30//!
31//! ### Configuration Errors
32//! Errors related to invalid pipeline or system configuration:
33//!
34//!
35//! ### Processing Errors
36//! Errors that occur during file processing operations:
37//!
38//!
39//! ### Validation Errors
40//! Errors from input validation and business rule violations:
41//!
42//!
43//! ### Infrastructure Errors
44//! Errors from external systems and infrastructure:
45//!
46//!
47//! ## Error Handling Patterns
48//!
49//! ### Pattern Matching
50//! Use pattern matching for granular error handling:
51//!
52//!
53//! ### Error Propagation
54//! Use the `?` operator for clean error propagation:
55//!
56//!
57//! ### Error Context
58//! Add context to errors for better debugging:
59//!
60//!
61//! ## Error Conversion
62//!
63//! Domain errors can be converted to other error types:
64//!
65//!
66//! ## Testing with Errors
67//!
68//! ```rust
69//! #[cfg(test)]
70//! mod tests {
71//! use super::*;
72//!
73//! #[test]
74//! fn test_error_display() {
75//! // Test error messages are informative
76//! }
77//!
78//! #[test]
79//! fn test_error_conversion() {
80//! // Test error type conversions
81//! }
82//!
83//! #[test]
84//! fn test_error_recovery() {
85//! // Test error recovery strategies
86//! }
87//! }
88//! ```
89//!
90//! ## Best Practices
91//!
92//! - **Be Specific**: Use specific error variants for different failure
93//! scenarios
94//! - **Include Context**: Always include relevant context in error messages
95//! - **Avoid Strings**: Use typed error variants instead of generic string
96//! errors
97//! - **Document Errors**: Document which errors can be returned from functions
98//! - **Test Error Paths**: Ensure error handling paths are tested
99
100mod pipeline_error;
101
102pub use pipeline_error::PipelineError;