clawhdf5-remote: a failed first fetch is Error::Remote
cached() mapped an error of its open-time prefetch (a network error, a changed file) to Error::Hdf5(Format(Storage)), misclassifying it for callers that match on the variant. It is now Error::Remote (RemoteError::Backend with the backend's message). open_object and the s3/gs/az URLs fetch the first block of an ObjectStoreStorage directly, so their errors keep their kind (FileChanged, ObjectStore). Test: cached() over a backend whose reads fail gives Error::Remote(Backend) (Error::Hdf5 before). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
@@ -834,3 +834,27 @@ fn slow_links_read_and_stalled_ones_fail() {
|
||||
assert!(matches!(e, Error::Remote(RemoteError::Transport(_))), "{e}");
|
||||
assert!(t.elapsed() < Duration::from_secs(5), "{:?}", t.elapsed());
|
||||
}
|
||||
|
||||
/// `cached` reports a failed first fetch as a remote error, not as an
|
||||
/// HDF5 format error.
|
||||
#[test]
|
||||
fn cached_reports_a_failed_prefetch_as_remote() {
|
||||
use clawhdf5_format::error::FormatError;
|
||||
use std::borrow::Cow;
|
||||
struct Down;
|
||||
impl clawhdf5_format::storage::Storage for Down {
|
||||
fn read_at(&self, _: u64, _: usize) -> Result<Cow<'_, [u8]>, FormatError> {
|
||||
Err(RemoteError::Transport("connection refused".into()).into())
|
||||
}
|
||||
fn len(&self) -> u64 {
|
||||
1 << 20
|
||||
}
|
||||
}
|
||||
let e = clawhdf5_remote::cached(Box::new(Down), &Options::default())
|
||||
.map(|_| ())
|
||||
.unwrap_err();
|
||||
assert!(
|
||||
matches!(&e, Error::Remote(RemoteError::Backend(m)) if m.contains("connection refused")),
|
||||
"{e:?}"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user