1use crate::{PortError, ViewError};
2use displaydoc::Display;
3use std::fmt::Debug;
4use std::io;
5
6#[derive(Debug, Display, Eq, PartialEq, Clone, PartialOrd)]
8pub enum Error {
9 View(ViewError),
11 Port(PortError),
13 Fatal(String),
15 Io(String, IoContext),
17}
18
19#[derive(Debug, Display, Eq, PartialEq, Clone, PartialOrd)]
21pub enum IoContext {
22 TerminalResize,
24 TerminalInit,
26 TerminalPoll,
28 GracefulExit,
30 Drawing,
32}
33impl IoContext {
34 #[must_use]
36 pub fn wrap_lib(self, err: &Error) -> Error {
37 self.raw(err.to_string())
38 }
39 #[must_use]
41 pub fn wrap_io(self, err: &io::Error) -> Error {
42 self.raw(err.to_string())
43 }
44
45 #[must_use]
47 pub fn raw(self, err: String) -> Error {
48 Error::Io(err, self.clone())
49 }
50}
51
52#[derive(Debug, Eq, PartialEq, Copy, Clone, PartialOrd)]
54pub struct NoClientError {}