async_editor/error.rs
1use derive_more::From;
2
3pub type Result<T> = core::result::Result<T, Error>;
4
5#[derive(Debug, From)]
6pub enum Error {
7 Msg(&'static str),
8 /// [`SharedStdout`] has already dropped
9 RedrawRcError,
10 SharedStdoutClosed,
11 #[from]
12 Fmt(std::fmt::Error),
13 #[from]
14 Io(std::io::Error),
15 //#[from]
16 //SerdeJson(serde_json::Error)
17}
18
19impl core::fmt::Display for Error {
20 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::result::Result<(), core::fmt::Error> {
21 write!(fmt, "{self:?}")
22 }
23}
24
25impl std::error::Error for Error {}
26
27/*impl From<&'static str> for Error {
28 fn from(s: &'static str) -> Self {
29 Error::Msg(s)
30 }
31}
32
33
34pub fn msg<E: Into<Error>>(msg: &str) -> E {
35 move || msg.into()
36}*/
37//pub fn msg<E: Into<Error>>(msg: &str) -> impl FnOnce() -> E {
38// move || msg.into()
39//}
40// Need FnOnce
41//pub fn msg(msg: &str) -> Error {
42// msg.into()
43//}
44//pub fn err<E: Into<Error>>(msg: &str) -> impl FnOnce() -> E {
45// move || msg.into()
46//}