1use std::fmt;
2
3#[derive(Debug, Copy, Clone, PartialEq)]
4pub enum ErrorKind {
5 InternalFailure,
6}
7
8#[derive(Debug, Clone, PartialEq)]
9pub struct Error {
10 pub kind: ErrorKind,
11 pub message: String,
12}
13
14impl Error {
15 pub fn new(kind: ErrorKind, message: impl Into<String>) -> Error {
16 Error {
17 kind,
18 message: message.into(),
19 }
20 }
21
22 pub fn kind(&self) -> ErrorKind {
23 self.kind
24 }
25}
26
27impl fmt::Display for Error {
28 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
29 write!(f, "{}", self.message)
30 }
31}