use std::io;
use thiserror::Error;
use crate::anim::AnimFormat;
#[derive(Error, Debug)]
pub enum M2Error {
#[error("I/O error: {0}")]
Io(#[from] io::Error),
#[error("Invalid magic number: expected '{expected}', got '{actual}'")]
InvalidMagic { expected: String, actual: String },
#[error("Unsupported version: {0}")]
UnsupportedVersion(String),
#[error("Parse error: {0}")]
ParseError(String),
#[error("Validation error: {0}")]
ValidationError(String),
#[error("Conversion error: cannot convert from version {from} to {to}: {reason}")]
ConversionError { from: u32, to: u32, reason: String },
#[error("Chunk error: {0}")]
ChunkError(String),
#[error("Reference error: {0}")]
ReferenceError(String),
#[error("Internal error: {0}")]
InternalError(String),
#[error("ANIM format detection failed: {0}")]
AnimFormatError(String),
#[error("Legacy ANIM parsing error: {0}")]
LegacyAnimError(String),
#[error("ANIM format conversion error: from {from:?} to {to:?}: {reason}")]
AnimConversionError {
from: AnimFormat,
to: AnimFormat,
reason: String,
},
#[error("Invalid magic bytes: {0:?}")]
InvalidMagicBytes([u8; 4]),
#[error("Missing required MD21 chunk")]
MissingMD21Chunk,
#[error("Malformed chunk header")]
MalformedChunk,
#[error("Unknown FileDataID: {0}")]
UnknownFileDataId(u32),
#[error("Failed to resolve external file: {0}")]
ExternalFileError(String),
}
pub type Result<T> = std::result::Result<T, M2Error>;