osu_file_parser/osu_file/events/audio_sample/
error.rs

1use std::num::ParseIntError;
2
3use strum_macros::{EnumString, IntoStaticStr};
4use thiserror::Error;
5
6use crate::helper::macros::verbose_error_to_error;
7
8#[derive(Debug, Error, IntoStaticStr, EnumString)]
9#[non_exhaustive]
10pub enum ParseAudioSampleError {
11    #[error("Missing `time` field")]
12    MissingTime,
13    #[error("Invalid `time` value")]
14    InvalidTime,
15    #[error("Missing `layer` field")]
16    MissingLayer,
17    #[error("Invalid `layer` value")]
18    InvalidLayer,
19    #[error("Missing `volume` field")]
20    MissingVolume,
21    #[error("Invalid `volume` value")]
22    InvalidVolume,
23    #[error("Wrong event type")]
24    WrongEvent,
25    #[error("Missing `filepath` field")]
26    MissingFilepath,
27}
28
29verbose_error_to_error!(ParseAudioSampleError);
30
31#[derive(Debug, Error)]
32#[non_exhaustive]
33pub enum VolumeSetError {
34    /// The volume was too high, being higher than `100`.
35    #[error("The volume was too high, expected the range 1 ~ 100")]
36    VolumeTooHigh,
37}
38
39#[derive(Debug, Error)]
40#[non_exhaustive]
41pub enum ParseVolumeError {
42    #[error(transparent)]
43    ParseIntError(#[from] ParseIntError),
44    #[error(transparent)]
45    VolumeSetError(#[from] VolumeSetError),
46}