1use std::io;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
6pub enum WmoError {
7 #[error("IO error: {0}")]
8 Io(#[from] io::Error),
9
10 #[error("Invalid magic identifier: expected {expected:?}, found {found:?}")]
11 InvalidMagic { expected: [u8; 4], found: [u8; 4] },
12
13 #[error("Unexpected end of file")]
14 UnexpectedEof,
15
16 #[error("Invalid chunk size: {0}")]
17 InvalidChunkSize(u32),
18
19 #[error("Invalid version: {0}")]
20 InvalidVersion(u32),
21
22 #[error("Invalid format: {0}")]
23 InvalidFormat(String),
24
25 #[error("Unsupported conversion: from version {from} to {to}")]
26 UnsupportedConversion { from: u32, to: u32 },
27
28 #[error("Missing required chunk: {0}")]
29 MissingRequiredChunk(String),
30
31 #[error("Duplicate chunk: {0}")]
32 DuplicateChunk(String),
33
34 #[error("Parse error: {0}")]
35 ParseError(String),
36
37 #[error("Invalid reference: {field} value {value} exceeds maximum {max}")]
38 InvalidReference { field: String, value: u32, max: u32 },
39}
40
41pub type Result<T> = std::result::Result<T, WmoError>;