wowlab_parsers/parsers/access/
errors.rs1wowlab_engine_macros::define_error! {
2#[derive(Debug)]
4pub struct ParseAccessError {
5 kind: ParseAccessErrorKind,
6}
7
8#[derive(Debug, thiserror::Error)]
9enum ParseAccessErrorKind {
10 #[error("invalid character at position {position}")]
11 InvalidCharacter { position: usize },
12
13 #[error("unexpected token at position {position}")]
14 UnexpectedToken { position: usize },
15
16 #[error("expected target ID after '{keyword}:'")]
17 MissingTarget { keyword: &'static str },
18
19 #[error("unknown access type: {found}")]
20 UnknownAccessType { found: String },
21
22 #[error("unexpected end of input")]
23 UnexpectedEof,
24}
25}
26
27impl ParseAccessError {
28 pub(super) const fn invalid_character(position: usize) -> Self {
29 Self {
30 kind: ParseAccessErrorKind::InvalidCharacter { position },
31 }
32 }
33
34 pub(super) const fn unexpected_token(position: usize) -> Self {
35 Self {
36 kind: ParseAccessErrorKind::UnexpectedToken { position },
37 }
38 }
39
40 pub(super) const fn missing_target(keyword: &'static str) -> Self {
41 Self {
42 kind: ParseAccessErrorKind::MissingTarget { keyword },
43 }
44 }
45
46 pub(super) fn unknown_access_type(found: String) -> Self {
47 Self {
48 kind: ParseAccessErrorKind::UnknownAccessType { found },
49 }
50 }
51
52 pub(super) const fn unexpected_eof() -> Self {
53 Self {
54 kind: ParseAccessErrorKind::UnexpectedEof,
55 }
56 }
57}