postwoman/src/errors.rs

53 lines
1.5 KiB
Rust
Raw Normal View History

2024-10-19 18:02:04 +02:00
#[derive(Debug, thiserror::Error)]
pub enum PostWomanError {
#[error("network error: {0:?}")]
Request(#[from] reqwest::Error),
#[error("invalid method: {0:?}")]
InvalidMethod(#[from] http::method::InvalidMethod),
2024-10-20 01:47:17 +02:00
#[error("invalid header: {0:?}")]
InvalidHeader(#[from] InvalidHeaderError),
2024-10-19 18:02:04 +02:00
#[error("contains Unprintable characters: {0:?}")]
Unprintable(#[from] reqwest::header::ToStrError),
#[error("header '{0}' not found in response")]
HeaderNotFound(String),
#[error("error opening collection: {0:?}")]
ErrorOpeningCollection(#[from] std::io::Error),
#[error("collection is not valid toml: {0:?}")]
InvalidCollection(#[from] toml::de::Error),
#[error("could not represent collection: {0:?}")] // should never happen
ErrorSerializingInternallyCollection(#[from] toml_edit::ser::Error),
#[error("invalid json payload: {0:?}")]
InvalidJson(#[from] serde_json::Error),
#[error("invalid regex: {0:?}")]
InvalidRegex(#[from] regex::Error),
2024-10-19 20:18:34 +02:00
2024-10-19 22:02:05 +02:00
#[error("request didn't match expected status code: {0:?}")]
UnexpectedStatusCode(reqwest::Response),
#[error("invalid Json Query: {0}")]
JQError(String),
2024-10-19 20:18:34 +02:00
#[error("regex failed matching in content: {0}")]
NoMatch(String),
2024-10-19 18:02:04 +02:00
}
2024-10-20 01:47:17 +02:00
#[derive(Debug, thiserror::Error)]
pub enum InvalidHeaderError {
#[error("invalid header name: {0:?}")]
Name(#[from] http::header::InvalidHeaderName),
#[error("invalid header value: {0:?}")]
Value(#[from] http::header::InvalidHeaderValue),
#[error("invalid header format: {0}")]
Format(String)
}