snix/tvix/castore/src/import/error.rs
Bob van der Linden 43e5c0ff0e feat(tvix/castore): ingest_entries: error on unexpected end of stream
Currently ingest_entries panics. This makes it hard to use
ingest_entries in parallel with other processes. When another process
runs into an error and wants to return so, while ingest_entries has
already started and has no entries yet, we're forced to panic.

With this change ingest_entries will return an error when there are no
entries, thus allowing the user to handle the errors as they please.

Change-Id: I78b85bf18f52af8c157d6bedad6019fd4398250a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/13146
Reviewed-by: flokli <flokli@flokli.de>
Autosubmit: Bob van der Linden <bobvanderlinden@gmail.com>
Reviewed-by: Bob van der Linden <bobvanderlinden@gmail.com>
Tested-by: BuildkiteCI
2025-02-25 01:19:55 +00:00

23 lines
731 B
Rust

use super::PathBuf;
use crate::Error as CastoreError;
/// Represents all error types that emitted by ingest_entries.
/// It can represent errors uploading individual Directories and finalizing
/// the upload.
/// It also contains a generic error kind that'll carry ingestion-method
/// specific errors.
#[derive(Debug, thiserror::Error)]
pub enum IngestionError<E: std::fmt::Display> {
#[error("error from producer: {0}")]
Producer(#[from] E),
#[error("failed to upload directory at {0}: {1}")]
UploadDirectoryError(PathBuf, CastoreError),
#[error("failed to finalize directory upload: {0}")]
FinalizeDirectoryUpload(CastoreError),
#[error("unexpected end of stream")]
UnexpectedEndOfStream,
}