27 lines
923 B
Rust
27 lines
923 B
Rust
//! runtime story 领域错误。
|
|
//!
|
|
//! 错误只表达运行时剧情规则失败,不能直接绑定 HTTP 或数据库错误模型。
|
|
|
|
use std::{error::Error, fmt};
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
pub enum RuntimeStoryRuleError {
|
|
MissingRuntimeSessionId,
|
|
MissingStoryAction,
|
|
UnsupportedStoryAction,
|
|
InvalidRuntimeSnapshot,
|
|
}
|
|
|
|
impl fmt::Display for RuntimeStoryRuleError {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
Self::MissingRuntimeSessionId => f.write_str("runtime_story.session_id 不能为空"),
|
|
Self::MissingStoryAction => f.write_str("runtime_story.action 不能为空"),
|
|
Self::UnsupportedStoryAction => f.write_str("runtime_story.action 当前不受支持"),
|
|
Self::InvalidRuntimeSnapshot => f.write_str("runtime_story.snapshot 非法"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Error for RuntimeStoryRuleError {}
|