Skip to main content

wow_blp/convert/
error.rs

1use ::image::error::ImageError;
2use thiserror::Error;
3
4/// Errors that can occur during BLP conversion operations
5#[derive(Debug, Error)]
6pub enum Error {
7    /// The requested mipmap level does not exist in the BLP file
8    #[error("There is no image in the BLP mipmaps level {0}!")]
9    MissingImage(usize),
10    /// Error during image conversion operations
11    #[error("Convertation error: {0}")]
12    Convert(#[from] ImageError),
13    /// Image width exceeds the maximum supported value of 65,535 pixels
14    #[error("Maximum value for width is 65,535")]
15    WidthTooLarge(u32),
16    /// Image height exceeds the maximum supported value of 65,535 pixels
17    #[error("Maximum value for height is 65,535")]
18    HeightTooLarge(u32),
19    /// Mismatch between header-declared size and actual pixel data size
20    #[error(
21        "Header sizes for mipmap {0} are {1}x{2}, but there are {3} pixels actually in content."
22    )]
23    MismatchSizes(usize, u32, u32, usize),
24    /// Mismatch between expected and actual alpha channel data size
25    #[error(
26        "Header sizes for mipmap {0} are {1}x{2}, but there are {3} alpha values actually in content."
27    )]
28    MismatchAlphaSizes(usize, u32, u32, usize),
29    /// Invalid alpha bit depth for Raw1 format (only 0, 1, 4, or 8 are valid)
30    #[error("There are invalid alpha bits for the Raw1 format. Got {0}, expected: 0, 1, 4, 8.")]
31    Raw1InvalidAlphaBits(u32),
32    /// Color map does not contain exactly 256 entries as required
33    #[error("Color map length {0}, 256 expected!")]
34    ColorMapLengthInvalid(usize),
35    /// Palette size mismatch (expected 256 colors)
36    #[error("Expected palette of 256 colors, but got {0}")]
37    PaletteWrongSize(usize),
38    /// Failed to convert decompressed DXT1 data to raw format
39    #[error("Failed to process bytes from DXT1 decomporession")]
40    Dxt1RawConvertFail,
41}