1use std::fmt;
2use std::fmt::{Debug, Formatter, Result as FmtResult};
3
4#[derive(Debug)]
5pub enum Error {
6 ZeroBytes,
7 ZeroLines,
8 StdIoError(std::io::Error),
9}
10
11impl std::error::Error for Error {}
12impl fmt::Display for Error {
13 fn fmt(&self, f: &mut Formatter) -> FmtResult {
14 write!(
15 f,
16 "FileRotateError:: {}",
17 match self {
18 Self::ZeroBytes => "Please specify number of bytes > 0.".to_owned(),
19 Self::ZeroLines => "Please specify number of lines > 0.".to_owned(),
20 Self::StdIoError(e) => format!("std::io::Error: {}", e),
21 }
22 )
23 }
24}
25impl From<std::io::Error> for Error {
26 fn from(err: std::io::Error) -> Self {
27 Self::StdIoError(err)
28 }
29}