sublime_cli_tools/error/mod.rs
1//! Error handling module for the CLI.
2//!
3//! This module defines all error types used in the CLI and provides user-friendly
4//! error messages and exit codes following the sysexits convention.
5//!
6//! # What
7//!
8//! Provides:
9//! - `CliError` enum for all CLI error cases
10//! - User-friendly error messages with suggestions
11//! - Exit code mapping following sysexits standards
12//! - Error context and conversion utilities
13//! - Enhanced error display with colors
14//!
15//! # How
16//!
17//! Wraps errors from internal crates (git, package, standard tools) and system
18//! operations into a unified `CliError` type that can be displayed to users with
19//! helpful context and suggestions. Exit codes follow the sysexits convention for
20//! proper shell integration.
21//!
22//! # Why
23//!
24//! Centralized error handling ensures consistent error messages and exit codes
25//! across all commands, improving user experience and making the CLI more
26//! predictable in scripts and automation.
27//!
28//! # Examples
29//!
30//! ```rust
31//! use sublime_cli_tools::error::{CliError, Result};
32//!
33//! fn example_operation() -> Result<()> {
34//! Err(CliError::configuration("Configuration file not found"))
35//! }
36//! ```
37//!
38//! Converting from library errors:
39//!
40//! ```rust
41//! use sublime_cli_tools::error::{CliError, Result};
42//! use sublime_git_tools::RepoError;
43//!
44//! fn git_operation() -> Result<()> {
45//! // Library errors are automatically converted
46//! let repo = sublime_git_tools::Repo::open("/path/to/repo")?;
47//! Ok(())
48//! }
49//! ```
50//!
51//! Enhanced error display:
52//!
53//! ```rust
54//! use sublime_cli_tools::error::{CliError, ErrorDisplay};
55//!
56//! let error = CliError::configuration("Config file not found");
57//! let display = ErrorDisplay::new(&error, true);
58//! println!("{}", display.format());
59//! ```
60
61mod cli_error;
62mod display;
63mod exit_codes;
64
65#[cfg(test)]
66mod tests;
67
68// Public re-exports
69pub use cli_error::{CliError, Result};
70pub use display::ErrorDisplay;
71pub use exit_codes::ExitCode;