//! AssetBundle error types. use thiserror::Error; /// AssetBundle parser error. #[derive(Error, Debug)] pub enum AssetBundleError { /// I/O error. #[error("IO error: {0}")] Io(#[from] std::io::Error), /// Parser reached malformed data while reading a named field. #[error("Parse error at offset {offset} while reading {field}: {message}")] ParseField { /// Field or structure name being read. field: String, /// Byte offset where parsing failed. offset: usize, /// Human-readable diagnostic. message: String, }, /// General parser error. #[error("Parse error: {0}")] Parse(String), /// Unsupported format or compression mode. #[error("Unsupported format: {0}")] UnsupportedFormat(String), /// Other error. #[error(transparent)] Other(#[from] anyhow::Error), } impl AssetBundleError { /// Creates a field-scoped parser error with byte offset context. pub fn parse_field( field: impl Into, offset: usize, message: impl Into, ) -> Self { Self::ParseField { field: field.into(), offset, message: message.into(), } } } /// AssetBundle result type. pub type Result = std::result::Result;