ascii_webcam/
error.rs

1//! # Error Handling
2//!
3//! This module defines custom error types and a Result type alias
4//! for use throughout the ASCII Webcam application.
5
6use color_eyre::Report;
7use thiserror::Error;
8
9/// A type alias for Results that use custom `AppError` type.
10pub type Result<T> = std::result::Result<T, Report>;
11
12/// Custom error types for the ASCII Webcam application.
13#[derive(Error, Debug)]
14#[allow(clippy::module_name_repetitions)]
15pub enum AppError {
16    /// Represents I/O errors.
17    #[error("IO error: {0}")]
18    Io(#[from] std::io::Error),
19
20    /// Represents OpenCV-related errors.
21    #[error("OpenCV error: {0}")]
22    OpenCV(#[from] opencv::Error),
23
24    /// Represents errors related to terminal operations.
25    #[error("Terminal error: {0}")]
26    Terminal(String),
27
28    /// Represents errors related to camera operations.
29    #[error("Camera error: {0}")]
30    Camera(String),
31
32    /// Represents unknown errors
33    #[allow(dead_code)]
34    #[error("Unexpected error occurred: {0}")]
35    Other(String),
36}