| 185 | |
| 186 | impl From<twilight_http::Error> for RequestError { |
| 187 | fn from(te: twilight_http::Error) -> Self { |
| 188 | use twilight_http::error::ErrorType as TwilightErrorType; |
| 189 | |
| 190 | match te.kind() { |
| 191 | TwilightErrorType::Response { status, .. } if status.get() == 401 => Self::InvalidToken, |
| 192 | TwilightErrorType::Unauthorized => Self::InvalidToken, |
| 193 | TwilightErrorType::Response { |
| 194 | error: ApiError::Ratelimited(RatelimitedApiError { retry_after, .. }), |
| 195 | .. |
| 196 | } => Self::Ratelimit(Duration::from_millis(*retry_after as u64)), |
| 197 | _ => Self::Other(te), |
| 198 | } |
| 199 | } |
| 200 | } |