aoer_plotty_rs/
errors.rs

1use std::fmt;
2
3
4#[derive(Debug)]
5pub enum SvgCreationError {
6    NullGeometry,
7}
8
9impl std::error::Error for SvgCreationError {}
10
11impl fmt::Display for SvgCreationError {
12    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
13        match self {
14            SvgCreationError::NullGeometry =>
15                write!(f, "Empty/Invalid/Dimensionless geometry"),
16        }
17    }
18}
19
20#[derive(Debug)]
21pub enum ContextError {
22    PoppedEmptyStack,
23    SvgGenerationError(String)
24}
25
26impl std::error::Error for ContextError {}
27
28impl fmt::Display for ContextError {
29    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
30        match self {
31            ContextError::PoppedEmptyStack =>
32                write!(f, "Popping from an empty context stack."),
33            ContextError::SvgGenerationError(msg) =>
34                write!(f, "Svg generation error: {}", msg),
35        }
36    }
37}