1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
//! Errors that can occur during request processing.
pub use super::ser::Error as SerializeError;
use crate::helix::BodyError;
#[cfg(feature = "client")]
#[cfg_attr(nightly, doc(cfg(feature = "client")))]
/// Errors for [`HelixClient::req_get`](super::super::HelixClient::req_get) and similar functions.
#[derive(thiserror::Error, Debug)]
// #[derive(displaydoc::Display)] https://github.com/yaahc/displaydoc/issues/15
pub enum ClientRequestError<RE: std::error::Error + Send + Sync + 'static> {
/// Request failed from reqwests side
#[error("request failed")]
RequestError(RE),
/// Request failed from reqwests side
#[error("body conversion failed")]
HyperError(#[from] hyper::Error),
/// No pagination found
#[error("no pagination found")]
NoPage,
/// Could not create request
#[error("could not create request")]
CreateRequestError(#[from] CreateRequestError),
/// Got error from GET response
#[error(transparent)]
HelixRequestGetError(#[from] HelixRequestGetError),
/// Got error from PUT response
#[error(transparent)]
HelixRequestPutError(#[from] HelixRequestPutError),
/// Got error from POST response
#[error(transparent)]
HelixRequestPostError(#[from] HelixRequestPostError),
/// Got error from PATCH response
#[error(transparent)]
HelixRequestPatchError(#[from] HelixRequestPatchError),
/// Got error from DELETE response
#[error(transparent)]
HelixRequestDeleteError(#[from] HelixRequestDeleteError),
/// Custom error
#[error("{0}")]
Custom(std::borrow::Cow<'static, str>),
}
/// Could not create request
#[derive(thiserror::Error, Debug, displaydoc::Display)]
pub enum CreateRequestError {
/// http crate returned an error
HttpError(#[from] http::Error),
/// serialization of body failed
SerializeError(#[from] BodyError),
/// could not assemble URI for request
InvalidUri(#[from] InvalidUri),
/// {0}
Custom(std::borrow::Cow<'static, str>),
}
/// Errors that can happen when creating [`http::Uri`] for [`Request`](super::Request)
#[derive(thiserror::Error, Debug, displaydoc::Display)]
pub enum InvalidUri {
/// URI could not be parsed
UriParseError(#[from] http::uri::InvalidUri),
/// could not assemble URI for request
UrlError(#[from] url::ParseError),
/// could not serialize request to query
QuerySerializeError(#[from] SerializeError),
}
/// Could not parse GET response
#[derive(thiserror::Error, Debug, displaydoc::Display)]
pub enum HelixRequestGetError {
/// helix returned error {status:?} - {error}: {message:?} when calling `GET {uri}`
Error {
/// Error message related to status code
error: String,
/// Status code of error, usually 400-499
status: http::StatusCode,
/// Error message from Twitch
message: String,
/// URI to the endpoint
uri: http::Uri,
},
/// could not parse response as utf8 when calling `GET {2}`
Utf8Error(hyper::body::Bytes, #[source] std::str::Utf8Error, http::Uri),
/// deserialization failed when processing request response calling `GET {2}` with response: {3} - {0:?}
DeserializeError(
String,
#[source] crate::DeserError,
http::Uri,
http::StatusCode,
),
/// invalid or unexpected response from twitch.
InvalidResponse {
/// Reason for error
reason: &'static str,
/// Response text
response: String,
/// Status Code
status: http::StatusCode,
/// Uri to endpoint
uri: http::Uri,
},
}
/// Could not parse PUT response
#[derive(thiserror::Error, Debug, displaydoc::Display)]
pub enum HelixRequestPutError {
/// helix returned error {status:?} - {error}: {message:?} when calling `PUT {uri}` with a body
Error {
/// Error message related to status code
error: String,
/// Status code of error, usually 400-499
status: http::StatusCode,
/// Error message from Twitch
message: String,
/// URI to the endpoint
uri: http::Uri,
/// Body sent to PUT response
body: hyper::body::Bytes,
},
/// could not parse response as utf8 when calling `PUT {2}`
Utf8Error(hyper::body::Bytes, #[source] std::str::Utf8Error, http::Uri),
/// deserialization failed when processing request response calling `PUT {2}` with response: {3} - {0:?}
DeserializeError(
String,
#[source] crate::DeserError,
http::Uri,
http::StatusCode,
),
/// invalid or unexpected response from twitch.
InvalidResponse {
/// Reason for error
reason: &'static str,
/// Response text
response: String,
/// Status Code
status: http::StatusCode,
/// Uri to endpoint
uri: http::Uri,
},
}
/// Could not parse POST response
#[derive(thiserror::Error, Debug, displaydoc::Display)]
pub enum HelixRequestPostError {
/// helix returned error {status:?} - {error}: {message:?} when calling `POST {uri}` with a body
Error {
/// Error message related to status code
error: String,
/// Status code of error, usually 400-499
status: http::StatusCode,
/// Error message from Twitch
message: String,
/// URI to the endpoint
uri: http::Uri,
/// Body sent to POST response
body: hyper::body::Bytes,
},
/// could not parse response as utf8 when calling `POST {2}`
Utf8Error(hyper::body::Bytes, #[source] std::str::Utf8Error, http::Uri),
/// deserialization failed when processing request response calling `POST {2}` with response: {3} - {0:?}
DeserializeError(
String,
#[source] crate::DeserError,
http::Uri,
http::StatusCode,
),
/// invalid or unexpected response from twitch.
InvalidResponse {
/// Reason for error
reason: &'static str,
/// Response text
response: String,
/// Status Code
status: http::StatusCode,
/// Uri to endpoint
uri: http::Uri,
},
}
/// Could not parse PATCH response
#[derive(thiserror::Error, Debug, displaydoc::Display)]
pub enum HelixRequestPatchError {
/// helix returned error {status:?} - {error}: {message:?} when calling `PATCH {uri}` with a body
Error {
/// Error message related to status code
error: String,
/// Status code of error, usually 400-499
status: http::StatusCode,
/// Error message from Twitch
message: String,
/// URI to the endpoint
uri: http::Uri,
/// Body sent to POST response
body: hyper::body::Bytes,
},
/// could not parse response as utf8 when calling `POST {2}`
Utf8Error(hyper::body::Bytes, #[source] std::str::Utf8Error, http::Uri),
/// deserialization failed when processing request response calling `POST {2}` with response: {3} - {0:?}
DeserializeError(
String,
#[source] crate::DeserError,
http::Uri,
http::StatusCode,
),
/// invalid or unexpected response from twitch.
InvalidResponse {
/// Reason for error
reason: &'static str,
/// Response text
response: String,
/// Status Code
status: http::StatusCode,
/// Uri to endpoint
uri: http::Uri,
},
}
/// Could not parse DELETE response
#[derive(thiserror::Error, Debug, displaydoc::Display)]
pub enum HelixRequestDeleteError {
/// helix returned error {status:?} - {error}: {message:?} when calling `DELETE {uri}`
Error {
/// Error message related to status code
error: String,
/// Status code of error, usually 400-499
status: http::StatusCode,
/// Error message from Twitch
message: String,
/// URI to the endpoint
uri: http::Uri,
/// Body sent to DELETE response
body: hyper::body::Bytes,
},
/// could not parse response as utf8 when calling `DELETE {2}`
Utf8Error(hyper::body::Bytes, #[source] std::str::Utf8Error, http::Uri),
/// invalid or unexpected response from twitch.
InvalidResponse {
/// Reason for error
reason: &'static str,
/// Response text
response: String,
/// Status Code
status: http::StatusCode,
/// Uri to endpoint
uri: http::Uri,
},
}