1use std::error::Error as StdError;
2use std::fmt;
3
4#[non_exhaustive]
7#[derive(Debug, PartialEq)]
8pub enum Error {
9 EmptyRange,
10 StartGreaterThanEnd,
11 ParseStartPoint(std::num::ParseFloatError),
12 ParseEndPoint(std::num::ParseFloatError),
13}
14
15impl fmt::Display for Error {
16 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
17 match self {
18 Self::EmptyRange => write!(f, "the range string must not be empty"),
19 Self::StartGreaterThanEnd => {
20 write!(f, "the start point must be lesser than the end point")
21 }
22 Self::ParseStartPoint(e) => {
23 write!(f, "the start point could not be parsed as float: {}", e)
24 }
25 Self::ParseEndPoint(e) => {
26 write!(f, "the end point could not be parsed as float: {}", e)
27 }
28 }
29 }
30}
31
32impl StdError for Error {}