openjd_snapshots/error.rs
1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// Copyright by contributors to this project.
3// SPDX-License-Identifier: (Apache-2.0 OR MIT)
4
5use thiserror::Error;
6
7/// Errors that can occur during snapshot operations.
8#[derive(Debug, Error)]
9#[non_exhaustive]
10pub enum SnapshotError {
11 /// An I/O error occurred during file or directory operations.
12 #[error("IO error: {0}")]
13 Io(#[from] std::io::Error),
14
15 /// Manifest content failed validation (bad paths, missing hashes, etc.).
16 #[error("Manifest validation error: {0}")]
17 Validation(String),
18
19 /// A required file or directory was not found.
20 #[error("File not found: {0}")]
21 FileNotFound(String),
22
23 /// The operation was cancelled via the cancellation flag.
24 #[error("Operation cancelled")]
25 Cancelled,
26
27 /// A cache (hash cache or S3 check cache) operation failed.
28 #[error("Cache error: {0}")]
29 Cache(String),
30
31 /// An S3 or STS API call failed.
32 #[error("S3 error: {0}")]
33 S3(String),
34
35 /// A background task (tokio spawn/runtime) failed.
36 #[error("Task error: {0}")]
37 Task(String),
38}
39
40pub type Result<T> = std::result::Result<T, SnapshotError>;