thymeleaf 0.1.0-beta.0

A framework-neutral Thymeleaf-compatible dynamic template engine for Rust
Documentation
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 {}