jimage_rs/
error.rs

1use thiserror::Error;
2
3/// Represents errors that can occur while working with JImage files.
4#[derive(Debug, Error)]
5pub enum JImageError {
6    #[error("File is not a valid jimage. Found magic: {0:#010x}")]
7    Magic(u32),
8    #[error("Unsupported jimage version: {major_version}.{minor_version}")]
9    Version {
10        major_version: u16,
11        minor_version: u16,
12    },
13    #[error("Failed read from slice: [{from}..{to}]")]
14    RawRead { from: usize, to: usize },
15    #[error("Failed to create Utf8 string: {0}")]
16    Utf8(#[from] std::str::Utf8Error),
17    #[error("I/O error: {0}")]
18    Io(#[from] std::io::Error),
19    #[error("Internal error: {0}")]
20    Internal(String),
21}
22
23/// Type alias for a Result type that uses JImageError for error handling.
24pub type Result<T> = std::result::Result<T, JImageError>;