online_dsl_forge/rulepack_render/
error.rs1use std::error::Error;
2use std::fmt;
3
4#[derive(Debug, Clone, Eq, PartialEq)]
5pub struct RulepackRenderError {
6 message: String,
7}
8
9impl RulepackRenderError {
10 pub fn new(message: impl Into<String>) -> Self {
11 Self {
12 message: message.into(),
13 }
14 }
15}
16
17impl fmt::Display for RulepackRenderError {
18 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
19 formatter.write_str(&self.message)
20 }
21}
22
23impl Error for RulepackRenderError {}
24
25pub(crate) type RenderResult<T> = Result<T, RulepackRenderError>;
26
27pub(crate) fn fail<T>(message: impl Into<String>) -> RenderResult<T> {
28 Err(RulepackRenderError::new(message))
29}