1use std::path::PathBuf;
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
10#[non_exhaustive]
11pub enum Error {
12 #[error("I/O error at {path}: {source}")]
13 Io {
14 path: PathBuf,
15 #[source]
16 source: std::io::Error,
17 },
18
19 #[error("unsupported compression magic bytes {magic:02x?} in {path}")]
20 UnsupportedCompression { path: PathBuf, magic: Vec<u8> },
21
22 #[error(transparent)]
23 Rds(#[from] rd_rds::Error),
24
25 #[error(transparent)]
26 RdsFile(#[from] rd_rds::file::ReadError),
27
28 #[error("malformed help-db index: {0}")]
29 MalformedIndex(String),
30
31 #[error("unknown topic {topic:?}")]
32 UnknownTopic { topic: String },
33
34 #[error("unknown reference key {key:?}")]
35 UnknownReference { key: String },
36
37 #[error(
38 "record size mismatch: the 4-byte length prefix declares {expected} bytes but zlib decompression produced {actual} bytes"
39 )]
40 RecordSizeMismatch { expected: usize, actual: usize },
41}
42
43impl Error {
44 pub(crate) fn io(path: impl Into<PathBuf>, source: std::io::Error) -> Self {
45 Self::Io {
46 path: path.into(),
47 source,
48 }
49 }
50}