1#![warn(missing_docs)]
3#![warn(unsafe_code)]
4
5use std::fmt::{Debug, Display, Formatter};
6
7pub enum ErrorKind {
9 Message(String),
12}
13
14pub struct Error {
16 kind: ErrorKind,
17}
18
19impl Display for Error {
20 fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
21 match &self.kind {
22 ErrorKind::Message(m) => write!(f, "Some error occurred: {:?}", m),
23 }
24 }
25}
26
27impl Debug for Error {
28 fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
29 write!(f, "{}", self)
30 }
31}
32
33impl From<serde_json::Error> for Error {
34 fn from(e: serde_json::Error) -> Self {
35 Error {
36 kind: ErrorKind::Message(e.to_string()),
37 }
38 }
39}
40
41impl From<std::io::Error> for Error {
42 fn from(e: std::io::Error) -> Self {
43 Error {
44 kind: ErrorKind::Message(e.to_string()),
45 }
46 }
47}