editor_error.rs - icy_draw - [fork] icy_draw is the successor to mystic draw.
HTML git clone https://git.drkhsh.at/icy_draw.git
DIR Log
DIR Files
DIR Refs
DIR README
---
editor_error.rs (1066B)
---
1 use std::error::Error;
2
3 #[derive(Debug, Clone)]
4 pub enum EditorError {
5 CurrentLayerInvalid,
6
7 Error(String),
8 InvalidLayer(usize),
9 MergeLayerDownHasNoMergeLayer,
10 UndoStackEmpty,
11 }
12
13 impl std::fmt::Display for EditorError {
14 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15 match self {
16 EditorError::CurrentLayerInvalid => write!(f, "Current layer is invalid"),
17 EditorError::InvalidLayer(layer) => write!(f, "Layer {layer} is invalid"),
18 EditorError::Error(err) => write!(f, "Editor error: {err}"),
19 EditorError::MergeLayerDownHasNoMergeLayer => {
20 write!(f, "Merge layer down has no merge layer")
21 }
22 EditorError::UndoStackEmpty => write!(f, "Undo stack is empty"),
23 }
24 }
25 }
26
27 impl Error for EditorError {
28 fn description(&self) -> &str {
29 "use std::display"
30 }
31
32 fn source(&self) -> Option<&(dyn Error + 'static)> {
33 None
34 }
35
36 fn cause(&self) -> Option<&dyn Error> {
37 self.source()
38 }
39 }