use std::io::Error as IoError;
use object_store::Error as ExternalObjectStoreError;
use thiserror::Error;
use crate::ObjectPrefixError;
#[derive(Debug, Error)]
pub enum S3ObjectStoreError {
#[error("s3 object store credentials must include both access key id and secret access key")]
IncompleteCredentials,
#[error("s3 object store bucket must not be empty")]
EmptyBucket,
#[error("s3 object store region must not be empty")]
EmptyRegion,
#[error("s3 object store key prefix was invalid")]
InvalidKeyPrefix(#[source] ObjectPrefixError),
#[error("object body length did not match expected integrity")]
IntegrityLengthMismatch,
#[error("object body hash did not match expected integrity")]
IntegrityHashMismatch,
#[error("object key already exists with conflicting bytes")]
ExistingObjectConflict,
#[error("requested byte range exceeded stored object length")]
RangeOutOfBounds,
#[error("s3 listed an object outside the configured key prefix")]
InvalidListedKey,
#[error("upload parts list has invalid part numbering")]
InvalidUploadParts,
#[error("temporary file operation failed")]
Io(#[from] IoError),
#[error("object-store path conversion failed")]
Path(#[source] object_store::path::Error),
#[error("s3 object store runtime initialization failed")]
Runtime(#[source] IoError),
#[error("s3 object store runtime is unavailable")]
RuntimeUnavailable,
#[error("s3 object store operation failed")]
External(#[from] ExternalObjectStoreError),
}