oneline_template/function_executor/
function_error.rs1use std::fmt;
2use std::error::Error;
3
4pub struct FunctionError {
6 display: String,
7 debug: String,
8}
9
10impl FunctionError {
11 pub fn msg<E>(error: E) -> FunctionError
13 where E: fmt::Display + fmt::Debug + 'static,
14 {
15 let display = format!("{}", error);
16 let debug = format!("{:?}", error);
17 return FunctionError {
18 display,
19 debug,
20 }
21 }
22}
23
24impl fmt::Display for FunctionError {
25 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26 write!(f, "{}", self.display)
27 }
28}
29
30impl fmt::Debug for FunctionError {
31 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32 write!(f, "{}", self.debug)
33 }
34}
35
36impl <E>From<E> for FunctionError
37 where
38 E: Error,
39 E: 'static,
40{
41 fn from(error: E) -> Self {
42 return Self::msg(error);
43 }
44}