osu_file_parser/osu_file/osb/
error.rs

1use strum_macros::{EnumString, IntoStaticStr};
2use thiserror::Error;
3
4use crate::{helper::macros::verbose_error_to_error, osu_file::events};
5
6#[derive(Debug, Error, EnumString, IntoStaticStr)]
7#[non_exhaustive]
8pub enum ParseError {
9    /// Unexpected line before any section.
10    #[error("Unexpected line before any section")]
11    UnexpectedLine,
12    /// Duplicate section names defined.
13    #[error("There are multiple sections defined as the same name")]
14    DuplicateSections,
15    /// Unknown section name defined.
16    #[error("There is an unknown section")]
17    UnknownSection,
18    #[error(transparent)]
19    #[strum(disabled)]
20    ParseVariableError(#[from] ParseVariableError),
21    #[error(transparent)]
22    #[strum(disabled)]
23    ParseEventsError(#[from] events::ParseError),
24}
25
26verbose_error_to_error!(ParseError);
27
28#[derive(Debug, Error, EnumString, IntoStaticStr)]
29#[non_exhaustive]
30pub enum ParseVariableError {
31    #[error("Missing the header `$`")]
32    MissingHeader,
33    #[error("Missing `=` for assignment")]
34    MissingEquals,
35}
36
37verbose_error_to_error!(ParseVariableError);