web_scrape/scrape/
error.rs1use std::fmt::{Display, Formatter};
2
3#[derive(Debug)]
5pub enum Error {
6 InvalidSelection { selection: String, message: String },
8
9 ExpectedOneGotMultiple { selection: String },
11
12 ExpectedOneGotNone { selection: String },
14
15 ExpectedOptionalGotMultiple { selection: String },
17}
18
19impl Display for Error {
20 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
21 match self {
22 Self::InvalidSelection { selection, message } => {
23 write!(f, "invalid selection '{}': {}", selection, message)
24 }
25 Self::ExpectedOneGotMultiple { selection } => {
26 write!(f, "expected one, got multiple: {}", selection)
27 }
28 Self::ExpectedOneGotNone { selection } => {
29 write!(f, "expected one, got none: {}", selection)
30 }
31 Self::ExpectedOptionalGotMultiple { selection } => {
32 write!(f, "expected one or none, got multiple: {}", selection)
33 }
34 }
35 }
36}
37
38impl std::error::Error for Error {}