Skip to content

Commit 9882500

Browse files
ZENOTMEZENOTME
andauthored
feat: add retryable property for Error (#1383)
## Which issue does this PR close? This PR is the first part of #964. ## What changes are included in this PR? Before we support retryable process, this PR add retryable property for Error. ## Are these changes tested? Co-authored-by: ZENOTME <st810918843@gmail.com>
1 parent bcc9909 commit 9882500

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

crates/catalog/rest/src/catalog.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,8 @@ impl Catalog for RestCatalog {
770770
return Err(Error::new(
771771
ErrorKind::Unexpected,
772772
"CommitFailedException, one or more requirements failed. The client may retry.",
773-
));
773+
)
774+
.with_retryable(true));
774775
}
775776
StatusCode::INTERNAL_SERVER_ERROR => {
776777
return Err(Error::new(

crates/iceberg/src/error.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ pub struct Error {
134134

135135
source: Option<anyhow::Error>,
136136
backtrace: Backtrace,
137+
138+
retryable: bool,
137139
}
138140

139141
impl Display for Error {
@@ -225,9 +227,17 @@ impl Error {
225227
// `Backtrace::capture()` will check if backtrace has been enabled
226228
// internally. It's zero cost if backtrace is disabled.
227229
backtrace: Backtrace::capture(),
230+
231+
retryable: false,
228232
}
229233
}
230234

235+
/// Set retryable of the error.
236+
pub fn with_retryable(mut self, retryable: bool) -> Self {
237+
self.retryable = retryable;
238+
self
239+
}
240+
231241
/// Add more context in error.
232242
pub fn with_context(mut self, key: &'static str, value: impl Into<String>) -> Self {
233243
self.context.push((key, value.into()));

0 commit comments

Comments
 (0)