use crate::error::FileError;
use crate::error::NoteError;
use core::str::Utf8Error;
use std::sync::mpsc::RecvError;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum ViewerError {
#[error("All subscribers have disconnected.")]
AllSubscriberDiconnected,
#[error("Watcher: lost observed file. File was renamed.")]
LostRenamedFile,
#[error("Can not view non-text files.")]
MarkupLanguageNone,
#[error("URL path must start with `/`")]
UrlMustStartWithSlash,
#[error(
"Maximum open TCP connections ({max_conn}) exceeded. \
Can not handle request. Consider raising the configuration variable \
`tcp_connections_max` in the configuration file."
)]
TcpConnectionsExceeded { max_conn: usize },
#[error("Can not read TCP stream: {error}")]
StreamRead { error: std::io::Error },
#[error("Can not parse HTTP header in TCP stream: {source_str}")]
StreamParse { source_str: String },
#[error(
"Failed to render the HTML error page (cf. `{tmpl}` in configuration file).\n{source}"
)]
RenderErrorPage { tmpl: String, source: NoteError },
#[error(transparent)]
Notify(#[from] notify::Error),
#[error(transparent)]
Httparse(#[from] httparse::Error),
#[error(transparent)]
Recv(#[from] RecvError),
#[error(transparent)]
File(#[from] FileError),
#[error(transparent)]
Note(#[from] NoteError),
#[error(transparent)]
Utf8(#[from] Utf8Error),
#[error(transparent)]
Io(#[from] std::io::Error),
}