Skip to main content

thumb_rs/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur during thumbnail generation.
4#[derive(Error, Debug)]
5pub enum ThumbsError {
6    /// The specified file does not exist on disk.
7    #[error("File not found: {0}")]
8    FileNotFound(String),
9
10    /// The file extension is not recognized as a supported format.
11    #[error("Unsupported format: {0}")]
12    UnsupportedFormat(String),
13
14    /// The OS failed to decode or open the image data.
15    #[error("Failed to open image: {0}")]
16    ImageError(String),
17
18    /// Failed to write the thumbnail to the output path.
19    #[error("Failed to save thumbnail: {0}")]
20    SaveError(String),
21
22    /// A platform-specific API call failed (e.g., COM error on Windows,
23    /// QuickLook error on macOS).
24    #[error("Platform error: {0}")]
25    PlatformError(String),
26
27    /// The OS thumbnail provider returned no result.
28    /// On Windows: no registered IThumbnailProvider for this file type.
29    /// On macOS: QLThumbnailGenerator could not produce a representation.
30    #[error("Thumbnail generation failed: {0}")]
31    ThumbnailGenerationFailed(String),
32
33    /// The current platform is not supported (only macOS and Windows are).
34    #[error("Platform not supported")]
35    PlatformNotSupported,
36
37    /// Standard I/O error (file read/write failures).
38    #[error("IO error: {0}")]
39    IoError(#[from] std::io::Error),
40}