clap_version_flag/error.rs
1// Project: clap-version-flag
2// File: src\error.rs
3// Author: Hadi Cahyadi <cumulus13@gmail.com>
4// Date: 2025-12-12
5// Description:
6// License: MIT
7
8use thiserror::Error;
9
10/// Error type for clap-version-flag
11#[derive(Error, Debug)]
12pub enum VersionError {
13 /// Invalid hex color format
14 #[error("Invalid hex color format: '{0}'. Expected format: #RRGGBB or #RGB")]
15 InvalidHexColor(String),
16
17 /// I/O error
18 #[error("I/O error: {0}")]
19 IoError(#[from] std::io::Error),
20}
21
22impl VersionError {
23 /// Creates a new InvalidHexColor error
24 pub fn invalid_hex(color: &str) -> Self {
25 Self::InvalidHexColor(color.to_string())
26 }
27}