1use std::{
2 error::Error,
3 fmt::{self, Display, Formatter},
4 io,
5};
6
7#[derive(Debug)]
9#[non_exhaustive]
10pub enum HTMLMinifierError {
11 IOError(io::Error),
12 IncompleteInput,
13}
14
15impl From<io::Error> for HTMLMinifierError {
16 #[inline]
17 fn from(error: io::Error) -> Self {
18 HTMLMinifierError::IOError(error)
19 }
20}
21
22impl Display for HTMLMinifierError {
23 #[inline]
24 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
25 match self {
26 HTMLMinifierError::IOError(error) => Display::fmt(error, f),
27 HTMLMinifierError::IncompleteInput => f.write_str("The HTML input is incomplete."),
28 }
29 }
30}
31
32impl Error for HTMLMinifierError {
33 #[inline]
34 fn source(&self) -> Option<&(dyn Error + 'static)> {
35 match self {
36 HTMLMinifierError::IOError(error) => error.source(),
38 HTMLMinifierError::IncompleteInput => None,
39 }
40 }
41}