class_rs/
errors.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use std::fmt::Formatter;

#[derive(Debug)]
pub enum JavaError {
    ConstantTypeError(String),
    InvalidConstantId,
    StringNotFound,
}

impl std::fmt::Display for JavaError {
    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
        match self {
            JavaError::ConstantTypeError(message) => write!(f, "{}", message),
            JavaError::InvalidConstantId => write!(f, "Invalid constant id"),
            JavaError::StringNotFound => write!(f, "String not found"),
        }
    }
}

impl std::error::Error for JavaError {}