1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
use butck_policies::error::ChunkFailed;
use crate::chunker::context::ButckContext;
#[derive(Debug)]
pub struct ButckRWError {
kind: ButckRWErrorKind,
ctx: ButckContext,
}
#[derive(thiserror::Error, Debug)]
pub enum ButckRWErrorKind {
#[error("No butck storage found")]
NoButckStorageFound,
#[error("Chunking policy not specified")]
ChunkingPolicyNotSpecified,
#[error("Cannot enable both MemmapRead and StreamRead")]
ReadingMethodAmbiguous,
#[error("Multiple input files specified but only one output file allowed")]
OutputCountMismatch,
#[error("Invalid bidx file format")]
InvalidBidxFormat,
#[error("Chunk not found in storage: {0}")]
ChunkNotFound(String),
#[error("Failed to rebuild file: {0}")]
RebuildFailed(String),
#[error("Chunking failed: {0}")]
ChunkFailed(#[from] ChunkFailed),
#[error("IO error: {0}")]
IOError(#[from] std::io::Error),
}
impl std::fmt::Display for ButckRWError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.kind)
}
}
impl ButckRWError {
pub fn ctx(&self) -> &ButckContext {
&self.ctx
}
pub fn kind(&self) -> &ButckRWErrorKind {
&self.kind
}
}
impl ButckRWErrorKind {
pub fn pack(self, ctx: ButckContext) -> ButckRWError {
ButckRWError { kind: self, ctx }
}
}
|