Close DDD cleanup and tests-support closure
This commit is contained in:
@@ -1,3 +1,62 @@
|
||||
//! 运行时物品领域错误过渡落位。
|
||||
//! 运行时物品领域错误。
|
||||
//!
|
||||
//! 错误只表达物品/奇遇规则失败,例如 encounter 缺失或奖励字段非法。
|
||||
|
||||
use std::{error::Error, fmt};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum TreasureFieldError {
|
||||
MissingTreasureRecordId,
|
||||
MissingRuntimeSessionId,
|
||||
MissingStorySessionId,
|
||||
MissingActorUserId,
|
||||
MissingEncounterId,
|
||||
MissingEncounterName,
|
||||
MissingRewardItemId,
|
||||
MissingRewardItemCategory,
|
||||
MissingRewardItemName,
|
||||
InvalidRewardItemQuantity,
|
||||
MissingRewardItemStackKey,
|
||||
RewardEquipmentItemCannotStack,
|
||||
RewardNonStackableItemMustStaySingleQuantity,
|
||||
}
|
||||
|
||||
impl fmt::Display for TreasureFieldError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::MissingTreasureRecordId => {
|
||||
f.write_str("treasure_record.treasure_record_id 不能为空")
|
||||
}
|
||||
Self::MissingRuntimeSessionId => {
|
||||
f.write_str("treasure_record.runtime_session_id 不能为空")
|
||||
}
|
||||
Self::MissingStorySessionId => f.write_str("treasure_record.story_session_id 不能为空"),
|
||||
Self::MissingActorUserId => f.write_str("treasure_record.actor_user_id 不能为空"),
|
||||
Self::MissingEncounterId => f.write_str("treasure_record.encounter_id 不能为空"),
|
||||
Self::MissingEncounterName => f.write_str("treasure_record.encounter_name 不能为空"),
|
||||
Self::MissingRewardItemId => {
|
||||
f.write_str("treasure_record.reward_items[].item_id 不能为空")
|
||||
}
|
||||
Self::MissingRewardItemCategory => {
|
||||
f.write_str("treasure_record.reward_items[].category 不能为空")
|
||||
}
|
||||
Self::MissingRewardItemName => {
|
||||
f.write_str("treasure_record.reward_items[].item_name 不能为空")
|
||||
}
|
||||
Self::InvalidRewardItemQuantity => {
|
||||
f.write_str("treasure_record.reward_items[].quantity 必须大于 0")
|
||||
}
|
||||
Self::MissingRewardItemStackKey => {
|
||||
f.write_str("treasure_record.reward_items[].stack_key 不能为空")
|
||||
}
|
||||
Self::RewardEquipmentItemCannotStack => {
|
||||
f.write_str("treasure_record.reward_items[] 可装备物品不能标记为 stackable")
|
||||
}
|
||||
Self::RewardNonStackableItemMustStaySingleQuantity => {
|
||||
f.write_str("treasure_record.reward_items[] 不可堆叠物品必须固定为单槽位单数量")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for TreasureFieldError {}
|
||||
|
||||
Reference in New Issue
Block a user