100 lines
2.2 KiB
Rust
100 lines
2.2 KiB
Rust
use thiserror::Error;
|
|
|
|
#[derive (Debug, Error)]
|
|
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,
|
|
|
|
#[error ("Bad server address")]
|
|
BadServerAddress,
|
|
|
|
#[error (transparent)]
|
|
TomlSerialization (#[from] toml::ser::Error),
|
|
|
|
#[error ("unknown config error")]
|
|
Unknown,
|
|
}
|
|
|
|
// I'm not sure how important this is, but it was already in the code
|
|
|
|
#[derive (Debug, Error)]
|
|
pub enum ShuttingDownError {
|
|
#[error ("Relay is shutting down")]
|
|
ShuttingDown,
|
|
}
|
|
|
|
#[derive (Debug, Error)]
|
|
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),
|
|
}
|
|
|
|
#[derive (Debug, Error)]
|
|
pub enum RequestError {
|
|
#[error (transparent)]
|
|
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 ("Unknown server")]
|
|
UnknownServer,
|
|
|
|
#[error ("Bad request")]
|
|
BadRequest,
|
|
|
|
#[error ("Server never responded")]
|
|
ServerNeverResponded,
|
|
|
|
#[error ("Server timed out")]
|
|
ServerTimedOut,
|
|
|
|
#[error ("Relay shutting down")]
|
|
RelayShuttingDown,
|
|
|
|
#[error ("Error is mysterious!")]
|
|
Mysterious,
|
|
}
|
|
|
|
#[derive (Debug, Error)]
|
|
pub enum RelayError {
|
|
#[error ("Handlebars template file error")]
|
|
TemplateFile (#[from] handlebars::TemplateFileError),
|
|
|
|
#[error ("Hyper error")]
|
|
Hyper (#[from] hyper::Error),
|
|
}
|