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