summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs106
1 files changed, 90 insertions, 16 deletions
diff --git a/src/error.rs b/src/error.rs
index d368763..928f258 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -1,25 +1,99 @@
-use crate::chunkid::ChunkId;
+//! Errors from Obnam client.
+
+use crate::backup_run::BackupError;
+use crate::chunk::ClientTrustError;
+use crate::cipher::CipherError;
+use crate::client::ClientError;
+use crate::cmd::restore::RestoreError;
+use crate::config::ClientConfigError;
+use crate::db::DatabaseError;
+use crate::dbgen::GenerationDbError;
+use crate::generation::{LocalGenerationError, NascentError};
+use crate::genlist::GenerationListError;
+use crate::label::LabelError;
+use crate::passwords::PasswordError;
use std::path::PathBuf;
-use thiserror::Error;
+use std::time::SystemTimeError;
+use tempfile::PersistError;
-/// Define all the kinds of errors any part of this crate can return.
-#[derive(Debug, Error)]
+/// Define all the kinds of errors that functions corresponding to
+/// subcommands of the main program can return.
+///
+/// This collects all kinds of errors the Obnam client may get, for
+/// convenience.
+#[derive(Debug, thiserror::Error)]
pub enum ObnamError {
- #[error("Can't find backup '{0}'")]
- UnknownGeneration(String),
+ /// Error from chunk labels.
+ #[error(transparent)]
+ Label(#[from] LabelError),
+
+ /// Error listing generations on server.
+ #[error(transparent)]
+ GenerationListError(#[from] GenerationListError),
+
+ /// Error about client trust chunks.
+ #[error(transparent)]
+ ClientTrust(#[from] ClientTrustError),
+
+ /// Error saving passwords.
+ #[error("couldn't save passwords to {0}: {1}")]
+ PasswordSave(PathBuf, PasswordError),
+
+ /// Error using server HTTP API.
+ #[error(transparent)]
+ ClientError(#[from] ClientError),
+
+ /// Error in client configuration.
+ #[error(transparent)]
+ ClientConfigError(#[from] ClientConfigError),
+
+ /// Error making a backup.
+ #[error(transparent)]
+ BackupError(#[from] BackupError),
+
+ /// Error making a new backup generation.
+ #[error(transparent)]
+ NascentError(#[from] NascentError),
+
+ /// Error encrypting or decrypting.
+ #[error(transparent)]
+ CipherError(#[from] CipherError),
+
+ /// Error using local copy of existing backup generation.
+ #[error(transparent)]
+ LocalGenerationError(#[from] LocalGenerationError),
+
+ /// Error from generation database.
+ #[error(transparent)]
+ GenerationDb(#[from] GenerationDbError),
+
+ /// Error using a Database.
+ #[error(transparent)]
+ Database(#[from] DatabaseError),
+
+ /// Error restoring a backup.
+ #[error(transparent)]
+ RestoreError(#[from] RestoreError),
- #[error("Generation has more than one file with the name {0}")]
- TooManyFiles(PathBuf),
+ /// Error making temporary file persistent.
+ #[error(transparent)]
+ PersistError(#[from] PersistError),
- #[error("Server response did not have a 'chunk-meta' header for chunk {0}")]
- NoChunkMeta(ChunkId),
+ /// Error doing I/O.
+ #[error(transparent)]
+ IoError(#[from] std::io::Error),
- #[error("Wrong checksum for chunk {0}, got {1}, expected {2}")]
- WrongChecksum(ChunkId, String, String),
+ /// Error reading system clock.
+ #[error(transparent)]
+ SystemTimeError(#[from] SystemTimeError),
- #[error("Chunk is missing: {0}")]
- MissingChunk(ChunkId),
+ /// Error regarding JSON.
+ #[error(transparent)]
+ SerdeJsonError(#[from] serde_json::Error),
- #[error("Chunk is in store too many times: {0}")]
- DuplicateChunk(ChunkId),
+ /// Unexpected cache directories found.
+ #[error(
+ "found CACHEDIR.TAG files that aren't present in the previous backup, might be an attack"
+ )]
+ NewCachedirTagsFound,
}