1use std::{io, path::PathBuf, result};
2
3#[derive(Debug, thiserror::Error)]
4pub enum Error {
5 #[error("failed to create output file: {0}")]
6 CreatingOutputFile(#[source] io::Error),
7
8 #[error("failed to write archive signature: {0}")]
9 WritingSignature(#[source] io::Error),
10
11 #[error("failed to write archive header: {0}")]
12 WritingHeader(#[source] io::Error),
13
14 #[error("failed to write file records: {0}")]
15 WritingFileIndex(#[source] io::Error),
16
17 #[error("failed to write file records: {0}")]
18 WritingFileIndexCustom(String),
19
20 #[error("failed to write file data: {0}")]
21 WritingFileData(#[source] io::Error),
22
23 #[error("failed to open input file '{0}': {0}")]
24 OpeningInputFile(PathBuf, #[source] io::Error),
25
26 #[error("failed to read input file '{0}' metadata: {0}")]
27 ReadingInputFileMetadata(PathBuf, #[source] io::Error),
28
29 #[error("failed to archive file '{0}': {0}")]
30 ArchivingInputFile(PathBuf, #[source] io::Error),
31
32 #[error("failed to archive file '{0}: file size should not be larger than 4 GiB")]
33 InputFileLarger4GiB(PathBuf),
34
35 #[error("failed to archive file '{0}: file name should not be longer than {1}")]
36 InputFileNameTooLong(String, usize),
37
38 #[error("failed to archive file '{0}: invalid file name: {1}")]
39 InvalidInputFileName(PathBuf, #[source] io::Error),
40
41 #[error("failed to archive file '{0}: file name can only contain ascii characters")]
42 InputFileNotAscii(String),
43
44 #[error("failed to archive file '{0}: file should be in folder")]
45 InputFileNotInFolder(String),
46
47 #[error("failed to archive file '{file}': duplicate hash {hash} for file {existing_file}")]
48 InputFileDuplicateHash {
49 file: String,
50 existing_file: String,
51 hash: String,
52 },
53
54 #[error("total size of files cannot be larger than 4GiB")]
55 TotalInputLarger4GiB,
56
57 #[error("output file cannot be larger than 4GiB")]
58 OutputFileLarger4GiB,
59
60 #[error("invalid option `{0}`: {1}")]
61 InvalidParameter(&'static str, String),
62
63 #[error("{0}")]
64 Other(String),
65}
66
67pub type Result<T> = result::Result<T, Error>;