rbatis_codegen/codegen/syntax_tree_pysql/
error.rs1use std::error::Error as StdError;
3use std::fmt::{self, Debug, Display};
4use std::io;
5
6pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Debug)]
10#[non_exhaustive]
11pub enum Error {
12 E(String),
14}
15
16impl Display for Error {
17 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20 match self {
21 Error::E(error) => write!(f, "{}", error),
22 }
23 }
24}
25
26impl StdError for Error {}
27
28impl From<io::Error> for Error {
29 #[inline]
30 fn from(err: io::Error) -> Self {
31 Error::from(err.to_string())
32 }
33}
34
35impl From<&str> for Error {
36 fn from(arg: &str) -> Self {
37 return Error::from(arg.to_string());
38 }
39}
40
41impl From<String> for Error {
42 fn from(arg: String) -> Self {
43 return Error::E(arg);
44 }
45}
46
47impl From<&dyn std::error::Error> for Error {
48 fn from(arg: &dyn std::error::Error) -> Self {
49 return Error::from(arg.to_string());
50 }
51}
52
53impl Clone for Error {
54 fn clone(&self) -> Self {
55 Error::from(self.to_string())
56 }
57
58 fn clone_from(&mut self, source: &Self) {
59 *self = Self::from(source.to_string());
60 }
61}