1use std::{error::Error, fmt, io};
4
5#[derive(Debug)]
7pub enum LogError {
8 IoError(io::Error),
10 DirectoryCreationError(String),
12 FormattingError(String),
14}
15
16impl fmt::Display for LogError {
17 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18 match self {
19 LogError::IoError(err) => write!(f, "I/O error: {}", err),
20 LogError::DirectoryCreationError(msg) => {
21 write!(f, "Failed to create directory: {}", msg)
22 }
23 LogError::FormattingError(msg) => write!(f, "Formatting error: {}", msg),
24 }
25 }
26}
27
28impl Error for LogError {}
29
30impl From<io::Error> for LogError {
31 fn from(err: io::Error) -> Self {
32 LogError::IoError(err)
33 }
34}