1#[derive(Debug, thiserror::Error)]
2pub enum Error {
3 #[error("class read error")]
4 ClassRead(#[source] ClassReadError),
5 #[error("class write error")]
6 ClassWriter(#[source] ClassWriteError),
7}
8
9#[derive(thiserror::Error, Debug)]
10pub enum ClassReadError {
11 #[error("unexpected end of input")]
12 UnexpectedEof,
13 #[error("invalid magic 0x{0:08x}")]
14 InvalidMagic(u32),
15 #[error("invalid class major version {0}")]
16 InvalidClassVersion(u16),
17 #[error("invalid constant pool tag {0}")]
18 InvalidConstantPoolTag(u8),
19 #[error("invalid constant pool index {0}")]
20 InvalidIndex(u16),
21 #[error("invalid attribute {0}")]
22 InvalidAttribute(String),
23 #[error("invalid opcode 0x{opcode:02x} at {offset}")]
24 InvalidOpcode {
25 opcode: u8,
27 offset: usize,
29 },
30 #[error("modified utf8 error: {0}")]
31 Utf8Error(String),
32}
33
34#[derive(Debug, thiserror::Error)]
35pub enum ClassWriteError {
36 #[error("missing constant pool")]
37 MissingConstantPool,
38 #[error("invalid constant pool")]
39 InvalidConstantPool,
40 #[error("invalid opcode 0x{opcode:02X} at offset {offset}")]
41 InvalidOpcode { opcode: u8, offset: usize },
42 #[error("frame computation error: {0}")]
43 FrameComputation(String),
44}