Skip to main content

rvt/
error.rs

1use std::io;
2use thiserror::Error;
3
4pub type Result<T, E = Error> = std::result::Result<T, E>;
5
6#[derive(Debug, Error)]
7pub enum Error {
8    #[error("I/O error: {0}")]
9    Io(#[from] io::Error),
10
11    #[error("Not a Revit file (magic bytes did not match CFB/OLE)")]
12    NotACfbFile,
13
14    #[error("CFB: {0}")]
15    Cfb(String),
16
17    #[error("Stream not found: {0}")]
18    StreamNotFound(String),
19
20    #[error("Decompression failed: {0}")]
21    Decompress(String),
22
23    /// A bounded-decompression call refused to continue because its
24    /// output budget would be exceeded. Raised by
25    /// [`crate::compression::inflate_at_with_limits`] and its
26    /// aggregate-budget cousin. Distinct from the generic
27    /// `Decompress` variant so callers can distinguish "corrupt
28    /// input" from "well-formed input that would inflate beyond the
29    /// configured DoS ceiling."
30    #[error("Decompression output limit exceeded: {0}")]
31    DecompressLimitExceeded(String),
32
33    #[error("Malformed BasicFileInfo: {0}")]
34    BasicFileInfo(String),
35
36    #[error("Malformed PartAtom XML: {0}")]
37    PartAtom(String),
38
39    #[error("Invalid UTF-16: {0}")]
40    Utf16(String),
41
42    /// A caller-supplied [`crate::control::CancelToken`] was cancelled
43    /// while a scan was running. Partial results are discarded; the
44    /// file itself is fine.
45    #[error("operation cancelled by caller")]
46    Cancelled,
47}