1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//! # Error handling for `sublime_standard_tools`
//!
//! ## What
//! This module provides comprehensive error types for various operations within
//! the crate. It implements specific error types for different domains, such as
//! filesystem operations, command execution, and project management.
//!
//! ## How
//! Each domain has its own error type (e.g., `FileSystemError`) that implements
//! the `Error` trait from the standard library and uses the `thiserror` crate
//! for concise error definitions. Result type aliases are provided for convenience.
//!
//! ## Why
//! A structured approach to error handling enables callers to handle errors
//! appropriately based on their type and context, improving error reporting and
//! recovery strategies. The consistent pattern makes error handling predictable
//! across the crate.
use Result as CoreResult;
use Error as ThisError;
// Re-export error types
pub use ;
pub use ;
pub use FileSystemError;
pub use ;
pub use ;
pub use ErrorContext;
pub use ;
/// Result type for filesystem operations.
///
/// This is a convenience type alias for Results with `FileSystemError`.
///
/// # Examples
///
/// ```
/// use sublime_standard_tools::error::{FileSystemResult, FileSystemError};
/// use std::path::PathBuf;
///
/// fn read_config(path: &str) -> FileSystemResult<String> {
/// if path.is_empty() {
/// return Err(FileSystemError::Validation {
/// path: PathBuf::from(path),
/// reason: "Empty path".to_string(),
/// });
/// }
/// // Actual implementation would read the file
/// Ok("sample config".to_string())
/// }
/// ```
pub type FileSystemResult<T> = ;
/// General error type for the standard tools library.
///
/// This enum serves as a composite error type that aggregates all domain-specific
/// errors from the crate into a single error type. This allows for simplified error
/// handling in consumer code that may deal with multiple domains.
///
/// # Examples
///
/// ```
/// use sublime_standard_tools::error::{Error, FileSystemError, MonorepoError};
/// use std::path::PathBuf;
///
/// // Creating an error from a filesystem error
/// let fs_error = FileSystemError::NotFound { path: PathBuf::from("/missing/file.txt") };
/// let error: Error = fs_error.into();
///
/// // Creating an error from a monorepo error
/// let monorepo_error = MonorepoError::ManagerNotFound;
/// let error: Error = monorepo_error.into();
///
/// // Using in a function that could have multiple error sources
/// fn complex_operation() -> sublime_standard_tools::error::Result<()> {
/// // This could return either a FileSystem or Monorepo error
/// // Both will be automatically converted to the Error enum
/// Ok(())
/// }
/// ```
/// Result type for general operations in the standard tools library.
///
/// This is a convenience type alias for Results with the composite Error type.
/// It simplifies error handling when functions may return errors from various domains.
///
/// # Examples
///
/// ```
/// use sublime_standard_tools::error::{Result, Error, FileSystemError};
/// use std::path::PathBuf;
///
/// fn process_project_files(root_dir: &str) -> Result<Vec<String>> {
/// if root_dir.is_empty() {
/// return Err(FileSystemError::Validation {
/// path: PathBuf::from(root_dir),
/// reason: "Empty directory path".to_string(),
/// }.into());
/// }
/// // Implementation that might return various error types
/// Ok(vec!["file1.txt".to_string(), "file2.txt".to_string()])
/// }
/// ```
pub type Result<T> = ;