Skip to main content

vmdk/
error.rs

1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, VmdkError>;
4
5/// Errors returned while opening or parsing a VMDK image.
6#[derive(Debug, Error)]
7pub enum VmdkError {
8    #[error("I/O error: {0}")]
9    Io(#[from] std::io::Error),
10    #[error("not a VMware VMDK file: bad magic number")]
11    BadMagic,
12    #[error("unsupported VMDK version: {0}")]
13    UnsupportedVersion(u32),
14    #[error("compressed VMDKs are not supported")]
15    CompressedNotSupported,
16    #[error("VMDK file too small")]
17    FileTooSmall,
18    /// An arithmetic computation on a geometry field overflowed `u64`.
19    #[error("geometry field `{field}` overflowed")]
20    GeometryOverflow { field: &'static str },
21    /// A geometry field held a value outside its valid range.
22    #[error("geometry field `{field}` = {value} is invalid: {reason}")]
23    FieldOutOfRange {
24        /// The header/descriptor field that was out of range.
25        field: &'static str,
26        /// The offending value as read.
27        value: u64,
28        /// Why it is invalid (the expected range).
29        reason: &'static str,
30    },
31    /// The text descriptor was structurally malformed.
32    #[error("malformed descriptor: {0}")]
33    MalformedDescriptor(&'static str),
34    #[error("unsupported VMDK disk type: {0}")]
35    UnsupportedDiskType(String),
36}