nullnet_libconfmon/
error.rs1use std::fmt::{Display, Formatter, Result};
2
3#[derive(Debug, Clone)]
5pub enum ErrorKind {
6 ErrorInitializingWatcher,
7 ErrorWatchingFile,
8 ErrorReadingFile,
9 ErrorHandlingSnapshot,
10 ErrorUnsupportedPlatform,
11}
12
13impl Display for ErrorKind {
14 fn fmt(&self, f: &mut Formatter) -> Result {
16 match self {
17 ErrorKind::ErrorInitializingWatcher => write!(f, "ErrorInitializingWatcher"),
18 ErrorKind::ErrorWatchingFile => write!(f, "ErrorWatchingFile"),
19 ErrorKind::ErrorReadingFile => write!(f, "ErrorReadingFile"),
20 ErrorKind::ErrorHandlingSnapshot => write!(f, "ErrorHandlingSnapshot"),
21 ErrorKind::ErrorUnsupportedPlatform => write!(f, "ErrorUnsupportedPlatform"),
22 }
23 }
24}
25
26#[derive(Debug, Clone)]
32pub struct Error {
33 pub kind: ErrorKind,
34 pub message: String,
35}
36
37impl Display for Error {
38 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40 write!(f, "[{}] {}", self.kind, self.message)
41 }
42}