1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::fmt::{Display, Formatter};
/// 安全 OGNL 兼容层对外保留的求值异常。
///
/// 该对象只表达 Thymeleaf 可观察的 OGNL 求值失败,不开放 Java 反射能力。
/// 对应 Java: `ognl.OgnlException`。
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct OgnlError {
message: String,
}
impl OgnlError {
/// 创建包含 OGNL detail message 的异常。
///
/// # 参数
/// - `message`:与 Java OGNL 失败对应的详细消息。
#[must_use]
///
/// 对应 Java 语义:Rust 侧辅助函数(Java 无直接对应)。
pub fn new(message: String) -> Self {
Self { message }
}
/// 返回 Java 异常全限定名。
#[must_use]
pub const fn class_name(&self) -> &'static str {
"ognl.OgnlException"
}
}
impl Display for OgnlError {
fn fmt(&self, formatter: &mut Formatter<'_>) -> std::fmt::Result {
formatter.write_str(&self.message)
}
}
impl std::error::Error for OgnlError {}