2020-11-29 16:58:56 +00:00
|
|
|
use thiserror::Error;
|
|
|
|
|
2020-11-29 18:50:51 +00:00
|
|
|
#[derive (Debug, Error)]
|
2020-11-29 16:58:56 +00:00
|
|
|
pub enum ConfigError {
|
|
|
|
#[error ("I/O error")]
|
|
|
|
Io (#[from] std::io::Error),
|
|
|
|
|
|
|
|
#[error ("UTF-8 decoding failed")]
|
|
|
|
Utf8 (#[from] std::string::FromUtf8Error),
|
|
|
|
|
|
|
|
#[error ("TOML parsing failed")]
|
|
|
|
Toml (#[from] toml::de::Error),
|
|
|
|
|
|
|
|
#[error ("base64 decoding failed")]
|
|
|
|
Base64Decode (#[from] base64::DecodeError),
|
|
|
|
|
|
|
|
#[error ("tripcode not 32 bytes after decoding")]
|
|
|
|
TripcodeBadLength,
|
|
|
|
|
2021-04-27 23:48:22 +00:00
|
|
|
#[error ("Bad server address")]
|
|
|
|
BadServerAddress,
|
|
|
|
|
2020-11-29 16:58:56 +00:00
|
|
|
#[error ("unknown config error")]
|
|
|
|
Unknown,
|
|
|
|
}
|
|
|
|
|
|
|
|
// I'm not sure how important this is, but it was already in the code
|
|
|
|
|
2020-11-29 18:50:51 +00:00
|
|
|
#[derive (Debug, Error)]
|
2020-11-29 16:58:56 +00:00
|
|
|
pub enum ShuttingDownError {
|
|
|
|
#[error ("Relay is shutting down")]
|
|
|
|
ShuttingDown,
|
|
|
|
}
|
|
|
|
|
2020-11-29 18:50:51 +00:00
|
|
|
#[derive (Debug, Error)]
|
2020-11-29 18:37:33 +00:00
|
|
|
pub enum HandleHttpResponseError {
|
|
|
|
#[error ("HTTP error")]
|
|
|
|
Http (#[from] http::Error),
|
|
|
|
|
|
|
|
#[error ("Missing PTTH magic header")]
|
|
|
|
MissingPtthMagicHeader,
|
|
|
|
|
|
|
|
#[error ("PTTH magic header is not base64")]
|
|
|
|
PtthMagicHeaderNotBase64 (base64::DecodeError),
|
|
|
|
|
|
|
|
#[error ("PTTH magic header could not be decoded as MessagePack")]
|
|
|
|
PtthMagicHeaderNotMsgPack (rmp_serde::decode::Error),
|
|
|
|
|
|
|
|
#[error ("Couldn't tell server something")]
|
|
|
|
LostServer,
|
|
|
|
|
|
|
|
#[error ("Relaying task panicked")]
|
|
|
|
RelayingTaskPanicked (#[from] tokio::task::JoinError),
|
|
|
|
}
|
|
|
|
|
2020-11-29 18:50:51 +00:00
|
|
|
#[derive (Debug, Error)]
|
2020-11-29 18:37:33 +00:00
|
|
|
pub enum RequestError {
|
|
|
|
#[error ("HTTP error")]
|
|
|
|
Http (#[from] http::Error),
|
|
|
|
|
|
|
|
#[error ("MessagePack encode error")]
|
|
|
|
MsgPack (#[from] rmp_serde::encode::Error),
|
|
|
|
|
|
|
|
#[error ("Handlebars rendering error")]
|
|
|
|
Handlebars (#[from] handlebars::RenderError),
|
|
|
|
|
|
|
|
#[error ("Error handling HTTP response")]
|
|
|
|
HandleHttpResponse (#[from] HandleHttpResponseError),
|
|
|
|
|
|
|
|
#[error ("Error is mysterious!")]
|
|
|
|
Mysterious,
|
|
|
|
}
|
|
|
|
|
2020-11-29 18:50:51 +00:00
|
|
|
#[derive (Debug, Error)]
|
2020-11-29 16:58:56 +00:00
|
|
|
pub enum RelayError {
|
|
|
|
#[error ("Handlebars template file error")]
|
|
|
|
TemplateFile (#[from] handlebars::TemplateFileError),
|
2020-11-29 18:37:33 +00:00
|
|
|
|
|
|
|
#[error ("Hyper error")]
|
|
|
|
Hyper (#[from] hyper::Error),
|
2020-11-29 16:58:56 +00:00
|
|
|
}
|