wow_m2/
error.rs

1use std::io;
2use thiserror::Error;
3
4/// Error types for M2 model parsing and processing
5#[derive(Error, Debug)]
6pub enum M2Error {
7    /// I/O Error during reading or writing
8    #[error("I/O error: {0}")]
9    Io(#[from] io::Error),
10
11    /// Invalid magic number in the file header
12    #[error("Invalid magic number: expected '{expected}', got '{actual}'")]
13    InvalidMagic { expected: String, actual: String },
14
15    /// Unsupported file version
16    #[error("Unsupported version: {0}")]
17    UnsupportedVersion(String),
18
19    /// Error during parsing
20    #[error("Parse error: {0}")]
21    ParseError(String),
22
23    /// Error during validation
24    #[error("Validation error: {0}")]
25    ValidationError(String),
26
27    /// Error during version conversion
28    #[error("Conversion error: cannot convert from version {from} to {to}: {reason}")]
29    ConversionError { from: u32, to: u32, reason: String },
30
31    /// Chunk error: missing expected chunk or invalid chunk
32    #[error("Chunk error: {0}")]
33    ChunkError(String),
34
35    /// Reference error: invalid reference in the file
36    #[error("Reference error: {0}")]
37    ReferenceError(String),
38
39    /// Internal error: something went wrong in the parser logic
40    #[error("Internal error: {0}")]
41    InternalError(String),
42}
43
44/// Result type using M2Error
45pub type Result<T> = std::result::Result<T, M2Error>;