Skip to content

Commit 493a5d0

Browse files
fix: Add more details on what isn't implemented (#575)
Fixes #572.
1 parent 7b09e4e commit 493a5d0

File tree

5 files changed

+45
-12
lines changed

5 files changed

+45
-12
lines changed

src/aws/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ impl ObjectStore for AmazonS3 {
180180

181181
match (mode, &self.client.config.conditional_put) {
182182
(PutMode::Overwrite, _) => request.idempotent(true).do_put().await,
183-
(PutMode::Create, S3ConditionalPut::Disabled) => Err(Error::NotImplemented),
183+
(PutMode::Create, S3ConditionalPut::Disabled) => Err(Error::NotImplemented {
184+
operation:
185+
"`put_opts` with mode `PutMode::Create` when conditional put is disabled".into(),
186+
implementer: self.to_string(),
187+
}),
184188
(PutMode::Create, S3ConditionalPut::ETagMatch) => {
185189
match request.header(&IF_NONE_MATCH, "*").do_put().await {
186190
// Technically If-None-Match should return NotModified but some stores,
@@ -222,7 +226,12 @@ impl ObjectStore for AmazonS3 {
222226
r => r,
223227
}
224228
}
225-
S3ConditionalPut::Disabled => Err(Error::NotImplemented),
229+
S3ConditionalPut::Disabled => Err(Error::NotImplemented {
230+
operation:
231+
"`put_opts` with mode `PutMode::Update` when conditional put is disabled"
232+
.into(),
233+
implementer: self.to_string(),
234+
}),
226235
}
227236
}
228237
}

src/http/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ impl ObjectStore for HttpStore {
104104
) -> Result<PutResult> {
105105
if opts.mode != PutMode::Overwrite {
106106
// TODO: Add support for If header - https://datatracker.ietf.org/doc/html/rfc2518#section-9.4
107-
return Err(crate::Error::NotImplemented);
107+
return Err(crate::Error::NotImplemented {
108+
operation: "`put_opts` with a mode other than `PutMode::Overwrite`".into(),
109+
implementer: self.to_string(),
110+
});
108111
}
109112

110113
let response = self.client.put(location, payload, opts.attributes).await?;
@@ -125,7 +128,10 @@ impl ObjectStore for HttpStore {
125128
_location: &Path,
126129
_opts: PutMultipartOptions,
127130
) -> Result<Box<dyn MultipartUpload>> {
128-
Err(crate::Error::NotImplemented)
131+
Err(crate::Error::NotImplemented {
132+
operation: "`put_multipart_opts`".into(),
133+
implementer: self.to_string(),
134+
})
129135
}
130136

131137
async fn get_opts(&self, location: &Path, options: GetOptions) -> Result<GetResult> {

src/integration.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ pub async fn put_get_attributes(integration: &dyn ObjectStore) {
478478
let r = integration.get(&path).await.unwrap();
479479
assert_eq!(r.attributes, attributes);
480480
}
481-
Err(Error::NotImplemented) => {}
481+
Err(Error::NotImplemented { .. }) => {}
482482
Err(e) => panic!("{e}"),
483483
}
484484

@@ -491,7 +491,7 @@ pub async fn put_get_attributes(integration: &dyn ObjectStore) {
491491
let r = integration.get(&path).await.unwrap();
492492
assert_eq!(r.attributes, attributes);
493493
}
494-
Err(Error::NotImplemented) => {}
494+
Err(Error::NotImplemented { .. }) => {}
495495
Err(e) => panic!("{e}"),
496496
}
497497
}
@@ -606,7 +606,7 @@ pub async fn put_opts(storage: &dyn ObjectStore, supports_update: bool) {
606606
.put_opts(&path, "c".into(), PutMode::Update(v1.clone().into()).into())
607607
.await
608608
.unwrap_err();
609-
assert!(matches!(err, Error::NotImplemented), "{err}");
609+
assert!(matches!(err, Error::NotImplemented { .. }), "{err}");
610610

611611
return;
612612
}

src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,8 +2049,17 @@ pub enum Error {
20492049
},
20502050

20512051
/// Error when an operation is not implemented
2052-
#[error("Operation not yet implemented.")]
2053-
NotImplemented,
2052+
#[error("Operation {operation} not yet implemented by {implementer}.")]
2053+
NotImplemented {
2054+
/// What isn't implemented. Should include at least the method
2055+
/// name that was called; could also include other relevant
2056+
/// subcontexts.
2057+
operation: String,
2058+
2059+
/// Which driver this is that hasn't implemented this operation,
2060+
/// to aid debugging in contexts that may be using multiple implementations.
2061+
implementer: String,
2062+
},
20542063

20552064
/// Error when the used credentials don't have enough permission
20562065
/// to perform the requested operation

src/local.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,17 @@ impl ObjectStore for LocalFileSystem {
330330
opts: PutOptions,
331331
) -> Result<PutResult> {
332332
if matches!(opts.mode, PutMode::Update(_)) {
333-
return Err(crate::Error::NotImplemented);
333+
return Err(crate::Error::NotImplemented {
334+
operation: "`put_opts` with mode `PutMode::Update`".into(),
335+
implementer: self.to_string(),
336+
});
334337
}
335338

336339
if !opts.attributes.is_empty() {
337-
return Err(crate::Error::NotImplemented);
340+
return Err(crate::Error::NotImplemented {
341+
operation: "`put_opts` with `opts.attributes` specified".into(),
342+
implementer: self.to_string(),
343+
});
338344
}
339345

340346
let path = self.path_to_filesystem(location)?;
@@ -397,7 +403,10 @@ impl ObjectStore for LocalFileSystem {
397403
opts: PutMultipartOptions,
398404
) -> Result<Box<dyn MultipartUpload>> {
399405
if !opts.attributes.is_empty() {
400-
return Err(crate::Error::NotImplemented);
406+
return Err(crate::Error::NotImplemented {
407+
operation: "`put_multipart_opts` with `opts.attributes` specified".into(),
408+
implementer: self.to_string(),
409+
});
401410
}
402411

403412
let dest = self.path_to_filesystem(location)?;

0 commit comments

Comments
 (0)