osu_file_parser/osu_file/colours/
error.rs

1use strum_macros::{EnumString, IntoStaticStr};
2use thiserror::Error;
3
4use crate::helper::macros::verbose_error_to_error;
5
6#[derive(Debug, Error)]
7#[error(transparent)]
8pub struct ParseError(#[from] ParseColourError);
9
10/// Error used when there was a problem parsing a `str` as a `Colour`.
11#[derive(Debug, Error, EnumString, IntoStaticStr)]
12#[non_exhaustive]
13pub enum ParseColourError {
14    /// Invalid additive combo count.
15    #[error("Invalid additive combo count")]
16    InvalidComboCount,
17    /// Invalid colon separator.
18    #[error("Invalid colon separator")]
19    InvalidColonSeparator,
20    #[error(transparent)]
21    #[strum(disabled)]
22    ParseRgbError(#[from] ParseRgbError),
23    /// Unknown colour type.
24    #[error("Unknown colour type")]
25    UnknownColourType,
26}
27
28verbose_error_to_error!(ParseColourError);
29
30#[derive(Debug, Error, EnumString, IntoStaticStr)]
31#[non_exhaustive]
32pub enum ParseRgbError {
33    /// Invalid red value.
34    #[error("Invalid red value")]
35    InvalidRed,
36    /// Invalid green value.
37    #[error("Invalid green value")]
38    InvalidGreen,
39    /// Invalid blue value.
40    #[error("Invalid blue value")]
41    InvalidBlue,
42    /// Missing green value.
43    #[error("Missing green value")]
44    MissingGreen,
45    /// Missing blue value.
46    #[error("Missing blue value")]
47    MissingBlue,
48}
49
50verbose_error_to_error!(ParseRgbError);