tustvold commented on code in PR #4915:
URL: https://github.com/apache/arrow-rs/pull/4915#discussion_r1353243290
##########
object_store/src/client/retry.rs:
##########
@@ -23,46 +23,50 @@ use futures::FutureExt;
use reqwest::header::LOCATION;
use reqwest::{Response, StatusCode};
use snafu::Error as SnafuError;
+use snafu::Snafu;
use std::time::{Duration, Instant};
use tracing::info;
/// Retry request error
-#[derive(Debug)]
-pub struct Error {
- retries: usize,
- message: String,
- source: Option<reqwest::Error>,
- status: Option<StatusCode>,
-}
-
-impl std::fmt::Display for Error {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- write!(
- f,
- "response error \"{}\", after {} retries",
- self.message, self.retries
- )?;
- if let Some(source) = &self.source {
- write!(f, ": {source}")?;
- }
- Ok(())
- }
-}
-
-impl std::error::Error for Error {
- fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
- self.source.as_ref().map(|e| e as _)
- }
+#[derive(Debug, Snafu)]
+pub enum Error {
+ #[snafu(display("Received redirect without LOCATION, this normally
indicates an incorrectly configured region"))]
+ BareRedirect,
+
+ #[snafu(display("Client error with status {status}: {}",
body.as_deref().unwrap_or("No Body")))]
+ Client {
+ status: StatusCode,
+ body: Option<String>,
+ },
+
+ #[snafu(display("Response error after {retries} retries: {source}"))]
Review Comment:
I removed "Response" to avoid confusion
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]