cooplan_definitions_lib/
error.rs1use std::fmt;
2
3#[derive(Debug, Copy, Clone, PartialEq)]
4pub enum ErrorKind {
5 MissingId,
6 FailedToBorrowCategory,
7 ParentNotAvailable,
8 FailedToValidateCategory,
9 FailedToValidateSourceAttribute,
10}
11
12#[derive(Debug)]
13pub struct Error {
14 pub kind: ErrorKind,
15 pub message: String,
16}
17
18impl Error {
19 pub fn new(kind: ErrorKind, message: &str) -> Error {
20 Error {
21 kind,
22 message: message.to_string(),
23 }
24 }
25
26 pub fn kind(&self) -> ErrorKind {
27 self.kind
28 }
29}
30
31impl fmt::Display for Error {
32 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
33 write!(f, "{}", self.message)
34 }
35}