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
62
63
64
65
66
67
68
use crate::blob::BlobHash;
/// Everything that can go wrong configuring, writing or reading a trace.
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum TraceError {
/// An environment variable holds a value the configuration cannot use.
#[error("{var}={value:?} is not valid: {expected}")]
BadEnv {
/// The variable.
var: &'static str,
/// What it held.
value: String,
/// What it may hold.
expected: &'static str,
},
/// The trace was written in a format this reader does not know.
#[error(
"trace format {found} is newer than this reader ({supported}); it was written by icedwright {writer}"
)]
NewerFormat {
/// The format in the trace.
found: u32,
/// The newest format this reader reads.
supported: u32,
/// The icedwright version that wrote it.
writer: String,
},
/// A step refers to a blob the archive does not hold.
#[error("missing blob {0}")]
MissingBlob(BlobHash),
/// Reading or writing failed.
#[error(transparent)]
Io(#[from] std::io::Error),
/// The bytes are not a readable zip archive, or a member cannot be decompressed.
#[error("corrupt archive: {0}")]
Corrupt(String),
/// The archive lacks a member every trace has.
#[error("corrupt archive: no {0} member")]
MissingMember(&'static str),
/// A member holds something other than what the format says it holds.
#[error("corrupt archive: {member}{}: {reason}", line.map(|l| format!(" line {l}")).unwrap_or_default())]
BadMember {
/// The member's name inside the archive.
member: String,
/// The one-based line, for line-oriented members.
line: Option<usize>,
/// What is wrong with it.
reason: String,
},
/// A blob's content does not hash to its name.
#[error("corrupt archive: {member} hashes to {found}")]
BlobMismatch {
/// The member's name inside the archive.
member: String,
/// The hash of what it holds.
found: BlobHash,
},
/// Bytes given as a PNG are not one, or a frame could not be encoded.
#[error("not a PNG: {0}")]
Png(String),
/// A source file path that cannot be stored under `source/`.
#[error("source path {0:?} must be relative and stay inside the workspace")]
BadSourcePath(String),
/// An attachment name that is not a plain file name.
#[error("attachment name {0:?} must be a plain file name, with no directories")]
BadAttachmentName(String),
}