use std::num::ParseIntError;
use strum_macros::{EnumString, IntoStaticStr};
use thiserror::Error;
use crate::helper::macros::verbose_error_to_error;
#[derive(Debug, Error)]
#[error(transparent)]
pub struct ParseError(#[from] ParseHitObjectError);
#[derive(Debug, Error)]
#[error("Expected combo skip count to be 3 bits")]
pub struct ComboSkipCountTooHigh;
#[derive(Debug, Error, IntoStaticStr, EnumString)]
#[non_exhaustive]
pub enum ParseColonSetError {
#[error("Failed to parse the first item")]
InvalidFirstItem,
#[error("The colon separator is missing")]
MissingSeparator,
#[error("Failed to parse the second item")]
InvalidSecondItem,
}
verbose_error_to_error!(ParseColonSetError);
#[derive(Debug, Error, EnumString, IntoStaticStr)]
#[non_exhaustive]
pub enum ParseHitObjectError {
#[error("Invalid `hit_sound` value")]
InvalidHitSound,
#[error("Missing `hit_sound` field")]
MissingHitSound,
#[error("Missing `hit_sample` field")]
MissingHitSample,
#[error("Invalid `hit_sample` value")]
InvalidHitSample,
#[error("Invalid `x` value")]
InvalidX,
#[error("Missing `x` field")]
MissingX,
#[error("Invalid `y` value")]
InvalidY,
#[error("Missing `y` field")]
MissingY,
#[error("Missing `obj_type` field")]
MissingObjType,
#[error("Invalid `obj_type` value")]
InvalidObjType,
#[error("Missing `time` field")]
MissingTime,
#[error("Invalid `time` value")]
InvalidTime,
#[error("Invalid `curve_type` value")]
InvalidCurveType,
#[error("Missing `curve_type` field")]
MissingCurveType,
#[error("Invalid `curve_point` value")]
InvalidCurvePoint,
#[error("Missing `curve_point` field")]
MissingCurvePoint,
#[error("Invalid `edge_sound` value")]
InvalidEdgeSound,
#[error("Missing `edge_sound` field")]
MissingEdgeSound,
#[error("Invalid `edge_set` value")]
InvalidEdgeSet,
#[error("Missing `edge_set` field")]
MissingEdgeSet,
#[error("Invalid `slides_count` value")]
InvalidSlidesCount,
#[error("Missing `slides_count` field")]
MissingSlidesCount,
#[error("Invalid `length` value")]
InvalidLength,
#[error("Missing `length` field")]
MissingLength,
#[error("Invalid `end_time` value")]
InvalidEndTime,
#[error("Missing `end_time` field")]
MissingEndTime,
#[error("Unknown object type")]
UnknownObjType,
}
verbose_error_to_error!(ParseHitObjectError);
#[derive(Debug, Error, EnumString, IntoStaticStr)]
#[non_exhaustive]
pub enum ParseHitSampleError {
#[error("Invalid `sample_set` value")]
InvalidSampleSet,
#[error("Invalid `index` value")]
InvalidIndex,
#[error("Invalid `volume` value")]
InvalidVolume,
#[error("Missing field separator")]
MissingSeparator,
}
verbose_error_to_error!(ParseHitSampleError);
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ParseSampleSetError {
#[error("There was a problem parsing the `str` into an integer first")]
ParseValueError(#[from] ParseIntError),
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum VolumeSetError {
#[error("The volume was too high, expected to be in range 1 ~ 100")]
VolumeTooHigh,
#[error("The volume was attempted to set to 0, expected to be in range 1 ~ 100")]
VolumeTooLow,
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ParseVolumeError {
#[error(transparent)]
VolumeSetError(#[from] VolumeSetError),
#[error(transparent)]
ParseIntError(#[from] ParseIntError),
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ParseCurveTypeError {
#[error("Unknown `CurveType` variant")]
UnknownVariant,
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ParseHitSoundError {
#[error(transparent)]
ParseIntError(#[from] ParseIntError),
}