osu_file_parser/osu_file/general/
error.rs1use std::num::ParseIntError;
2
3use thiserror::Error;
4
5use crate::helper::{macros::unreachable_err_impl, ParseZeroOneBoolError};
6
7#[derive(Debug, Error)]
8#[non_exhaustive]
9pub enum ParseError {
11 #[error(transparent)]
13 ParseIntError(#[from] ParseIntError),
14 #[error(transparent)]
16 ParseZeroOneBoolError(#[from] ParseZeroOneBoolError),
17 #[error(transparent)]
19 ParseCountdownSpeedError(#[from] ParseCountdownSpeedError),
20 #[error(transparent)]
22 ParseGameModeError(#[from] ParseGameModeError),
23 #[error(transparent)]
24 ParseSampleSetError(#[from] ParseSampleSetError),
25 #[error(transparent)]
26 ParseOverlayPositionError(#[from] ParseOverlayPositionError),
27 #[error("Invalid colon set, expected format of `key: value`")]
29 InvalidColonSet,
30 #[error("The key doesn't exist in `General`")]
32 InvalidKey,
33 #[error("Duplicate field were found in `General`")]
35 DuplicateField,
36 #[error("Field doesn't exist in version")]
38 InvalidVersion,
39 #[error("Invalid comma list, expected format of `key: value, value, value, ...`")]
41 InvalidCommaList,
42}
43
44unreachable_err_impl!(ParseError);
45
46#[derive(Debug, Error)]
48#[non_exhaustive]
49pub enum ParseGameModeError {
50 #[error("Unknown `GameMode` variant")]
52 UnknownVariant,
53 #[error(transparent)]
55 ParseError(#[from] ParseIntError),
56}
57
58#[derive(Debug, Error)]
60#[non_exhaustive]
61pub enum ParseCountdownSpeedError {
62 #[error("Unknown `CountdownSpeed` variant")]
64 UnknownVariant,
65 #[error("There was a problem parsing the `str` as an `Integer`")]
67 ParseError(#[from] ParseIntError),
68}
69
70#[derive(Debug, Error)]
71#[non_exhaustive]
72pub enum ParseOverlayPositionError {
73 #[error("Unknown `OverlayPosition` variant")]
74 UnknownVariant,
75}
76
77#[derive(Debug, Error)]
78#[non_exhaustive]
79pub enum ParseSampleSetError {
80 #[error("Unknown `SampleSet` variant")]
81 UnknownVariant,
82}