atlas/error.rs
1use thiserror::Error;
2
3/// Every error returned by this crate. Each variant carries enough context
4/// to identify what failed; `Display` (via [`thiserror`]) renders the same
5/// message shown in the `///` line above each variant.
6#[derive(Debug, Error)]
7pub enum Error {
8 /// The named dataset doesn't exist in this store.
9 #[error("dataset not found: {0}")]
10 DatasetNotFound(String),
11 /// A dataset with this name was already created in this store.
12 #[error("dataset already exists: {0}")]
13 DatasetAlreadyExists(String),
14 /// The named array isn't defined in the relevant dataset.
15 #[error("array not found: {0}")]
16 ArrayNotFound(String),
17 /// An array with this name was already defined in the dataset.
18 #[error("array already exists: {0}")]
19 ArrayAlreadyExists(String),
20 /// `Atlas::open` / `open_path` was called against a location with no
21 /// metadata file (neither `atlas.json` nor any of the `atlas.msgpack*`
22 /// variants).
23 #[error("store not found at path")]
24 StoreNotFound,
25 /// Dataset or array name failed validation. Names must be non-empty,
26 /// cannot contain `/`, `..`, or `.`, and cannot start with `_`.
27 #[error("invalid name '{0}': must be non-empty, no '/', no '..', no leading '_'")]
28 InvalidName(String),
29 /// Underlying `array-format` failure — see the wrapped error for the
30 /// specific block/codec/storage problem.
31 #[error("array format error: {0}")]
32 ArrayFormat(#[from] array_format::Error),
33 /// Local filesystem I/O failure (used by `create_path` / `open_path`).
34 #[error("I/O error: {0}")]
35 Io(#[from] std::io::Error),
36 /// Failed to parse the JSON form of the store metadata.
37 #[error("metadata error: {0}")]
38 Meta(#[from] serde_json::Error),
39 /// Failed to encode store metadata to MessagePack (`atlas.msgpack` /
40 /// `atlas.msgpack.zst` / `atlas.msgpack.lz4`).
41 #[error("metadata encode error: {0}")]
42 MetaEncode(#[from] rmp_serde::encode::Error),
43 /// Failed to decode the MessagePack form of the store metadata.
44 #[error("metadata decode error: {0}")]
45 MetaDecode(#[from] rmp_serde::decode::Error),
46 /// Failed to LZ4-decompress the on-disk metadata file
47 /// (`atlas.json.lz4` / `atlas.msgpack.lz4`).
48 #[error("metadata lz4 decompress error: {0}")]
49 MetaLz4Decompress(#[from] lz4_flex::block::DecompressError),
50 /// Underlying `object_store` failure — bubbled up from the backend
51 /// (local FS, S3, GCS, Azure, in-memory).
52 #[error("object store error: {0}")]
53 ObjectStore(#[from] object_store::Error),
54}
55
56/// Convenience alias for `Result<T, atlas::Error>` returned by every
57/// fallible operation in the crate.
58pub type Result<T> = std::result::Result<T, Error>;