Close DDD cleanup and tests-support closure
This commit is contained in:
@@ -1,3 +1,40 @@
|
||||
//! 成长领域错误过渡落位。
|
||||
//! 成长领域错误。
|
||||
//!
|
||||
//! 错误保持纯领域语义,例如章节参数非法或经验来源不被接受。
|
||||
//! 错误保持纯领域语义,例如章节参数非法、经验预算非法或用户/章节标识缺失。
|
||||
|
||||
use std::{error::Error, fmt};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum ProgressionFieldError {
|
||||
MissingUserId,
|
||||
MissingChapterId,
|
||||
InvalidChapterIndex,
|
||||
InvalidTotalChapters,
|
||||
InvalidLevel,
|
||||
InvalidEntryExitLevel,
|
||||
InvalidXpBudget,
|
||||
InvalidExpectedHostileDefeatCount,
|
||||
}
|
||||
|
||||
impl fmt::Display for ProgressionFieldError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::MissingUserId => f.write_str("player_progression.user_id 不能为空"),
|
||||
Self::MissingChapterId => f.write_str("chapter_progression.chapter_id 不能为空"),
|
||||
Self::InvalidChapterIndex => {
|
||||
f.write_str("chapter_progression.chapter_index 必须大于 0")
|
||||
}
|
||||
Self::InvalidTotalChapters => f.write_str("chapter_progression.total_chapters 非法"),
|
||||
Self::InvalidLevel => f.write_str("player_progression.level 非法"),
|
||||
Self::InvalidEntryExitLevel => {
|
||||
f.write_str("chapter_progression.entry_level / exit_level 非法")
|
||||
}
|
||||
Self::InvalidXpBudget => f.write_str("chapter_progression 经验预算非法"),
|
||||
Self::InvalidExpectedHostileDefeatCount => {
|
||||
f.write_str("chapter_progression.expected_hostile_defeat_count 非法")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for ProgressionFieldError {}
|
||||
|
||||
Reference in New Issue
Block a user