zvault/src/repository/error.rs

110 lines
3.9 KiB
Rust
Raw Permalink Normal View History

2017-07-21 09:21:59 +00:00
use prelude::*;
2017-03-21 10:28:11 +00:00
2017-03-16 08:42:30 +00:00
use std::io;
use std::path::PathBuf;
2017-03-24 08:26:55 +00:00
use super::backup_file::BackupFileError;
use super::backup::BackupError;
2017-03-16 08:42:30 +00:00
use super::bundle_map::BundleMapError;
use super::config::ConfigError;
2017-03-22 08:19:16 +00:00
use super::metadata::InodeError;
2017-03-16 08:42:30 +00:00
quick_error!{
#[derive(Debug)]
2017-03-22 13:42:27 +00:00
#[allow(unknown_lints,large_enum_variant)]
2017-03-16 08:42:30 +00:00
pub enum RepositoryError {
NoRemote {
2018-02-24 12:19:51 +00:00
description(tr!("Remote storage not found"))
display("{}", tr_format!("Repository error: The remote storage has not been found, may be it needs to be mounted?"))
}
2017-03-22 08:19:16 +00:00
Index(err: IndexError) {
2017-03-16 08:42:30 +00:00
from()
cause(err)
2018-02-24 12:19:51 +00:00
description(tr!("Index error"))
display("{}", tr_format!("Repository error: index error\n\tcaused by: {}", err))
2017-03-16 08:42:30 +00:00
}
2017-03-22 08:19:16 +00:00
BundleDb(err: BundleDbError) {
2017-03-16 08:42:30 +00:00
from()
cause(err)
2018-02-24 12:19:51 +00:00
description(tr!("Bundle error"))
display("{}", tr_format!("Repository error: bundle db error\n\tcaused by: {}", err))
2017-03-16 08:42:30 +00:00
}
2017-03-22 08:19:16 +00:00
BundleWriter(err: BundleWriterError) {
2017-03-16 08:42:30 +00:00
from()
cause(err)
2018-02-24 12:19:51 +00:00
description(tr!("Bundle write error"))
display("{}", tr_format!("Repository error: failed to write to new bundle\n\tcaused by: {}", err))
2017-03-16 08:42:30 +00:00
}
2017-03-22 08:19:16 +00:00
BackupFile(err: BackupFileError) {
2017-03-16 08:42:30 +00:00
from()
cause(err)
2018-02-24 12:19:51 +00:00
description(tr!("Backup file error"))
display("{}", tr_format!("Repository error: backup file error\n\tcaused by: {}", err))
2017-03-16 08:42:30 +00:00
}
2017-03-22 08:19:16 +00:00
Chunker(err: ChunkerError) {
2017-03-16 08:42:30 +00:00
from()
cause(err)
2018-02-24 12:19:51 +00:00
description(tr!("Chunker error"))
display("{}", tr_format!("Repository error: failed to chunk data\n\tcaused by: {}", err))
2017-03-16 08:42:30 +00:00
}
2017-03-22 08:19:16 +00:00
Config(err: ConfigError) {
2017-03-21 09:52:48 +00:00
from()
cause(err)
2018-02-24 12:19:51 +00:00
description(tr!("Configuration error"))
display("{}", tr_format!("Repository error: configuration error\n\tcaused by: {}", err))
2017-03-21 09:52:48 +00:00
}
2017-03-22 08:19:16 +00:00
Inode(err: InodeError) {
2017-03-16 08:42:30 +00:00
from()
cause(err)
2018-02-24 12:19:51 +00:00
description(tr!("Inode error"))
display("{}", tr_format!("Repository error: inode error\n\tcaused by: {}", err))
2017-03-16 08:42:30 +00:00
}
2017-03-22 08:19:16 +00:00
LoadKeys(err: EncryptionError) {
2017-03-16 08:42:30 +00:00
from()
cause(err)
2018-02-24 12:19:51 +00:00
description(tr!("Failed to load keys"))
display("{}", tr_format!("Repository error: failed to load keys\n\tcaused by: {}", err))
2017-03-16 08:42:30 +00:00
}
2017-03-22 08:19:16 +00:00
BundleMap(err: BundleMapError) {
2017-03-16 08:42:30 +00:00
from()
cause(err)
2018-02-24 12:19:51 +00:00
description(tr!("Bundle map error"))
display("{}", tr_format!("Repository error: bundle map error\n\tcaused by: {}", err))
2017-03-16 08:42:30 +00:00
}
Integrity(err: IntegrityError) {
2017-03-16 08:42:30 +00:00
from()
cause(err)
2018-02-24 12:19:51 +00:00
description(tr!("Integrity error"))
display("{}", tr_format!("Repository error: integrity error\n\tcaused by: {}", err))
2017-03-18 16:22:11 +00:00
}
2017-04-10 18:15:13 +00:00
Dirty {
2018-02-24 12:19:51 +00:00
description(tr!("Dirty repository"))
display("{}", tr_format!("The repository is dirty, please run a check"))
2017-04-10 18:15:13 +00:00
}
2017-03-22 10:10:13 +00:00
Backup(err: BackupError) {
from()
cause(err)
2018-02-24 12:19:51 +00:00
description(tr!("Failed to create a backup"))
display("{}", tr_format!("Repository error: failed to create backup\n\tcaused by: {}", err))
2017-03-22 10:10:13 +00:00
}
2017-03-24 07:56:57 +00:00
Lock(err: LockError) {
from()
cause(err)
2018-02-24 12:19:51 +00:00
description(tr!("Failed to obtain lock"))
display("{}", tr_format!("Repository error: failed to obtain lock\n\tcaused by: {}", err))
2017-03-24 07:56:57 +00:00
}
2017-03-22 08:19:16 +00:00
Io(err: io::Error) {
2017-03-18 16:22:11 +00:00
from()
cause(err)
2018-02-24 12:19:51 +00:00
description(tr!("IO error"))
display("{}", tr_format!("IO error: {}", err))
2017-03-16 08:42:30 +00:00
}
2017-03-16 12:59:57 +00:00
NoSuchFileInBackup(backup: Backup, path: PathBuf) {
2018-02-24 12:19:51 +00:00
description(tr!("No such file in backup"))
display("{}", tr_format!("The backup does not contain the file {:?}", path))
2017-03-16 12:59:57 +00:00
}
2017-03-16 08:42:30 +00:00
}
}