73 lines
3.2 KiB
Rust
73 lines
3.2 KiB
Rust
//! 任务领域错误。
|
|
//!
|
|
//! 错误保持任务业务语义,例如字段缺失、步骤非法或任务尚未可交付。
|
|
|
|
use std::{error::Error, fmt};
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
pub enum QuestRecordFieldError {
|
|
MissingQuestId,
|
|
MissingRuntimeSessionId,
|
|
MissingActorUserId,
|
|
MissingIssuerNpcId,
|
|
MissingIssuerNpcName,
|
|
MissingTitle,
|
|
MissingDescription,
|
|
MissingRewardText,
|
|
EmptySteps,
|
|
MissingStepId,
|
|
MissingStepTitle,
|
|
MissingStepRevealText,
|
|
MissingStepCompleteText,
|
|
QuestNotReadyToTurnIn,
|
|
MissingRewardItemId,
|
|
MissingRewardItemCategory,
|
|
MissingRewardItemName,
|
|
InvalidRewardItemQuantity,
|
|
MissingRewardItemStackKey,
|
|
RewardEquipmentItemCannotStack,
|
|
RewardNonStackableItemMustStaySingleQuantity,
|
|
}
|
|
|
|
impl fmt::Display for QuestRecordFieldError {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
Self::MissingQuestId => f.write_str("quest_record.quest_id 不能为空"),
|
|
Self::MissingRuntimeSessionId => {
|
|
f.write_str("quest_record.runtime_session_id 不能为空")
|
|
}
|
|
Self::MissingActorUserId => f.write_str("quest_record.actor_user_id 不能为空"),
|
|
Self::MissingIssuerNpcId => f.write_str("quest_record.issuer_npc_id 不能为空"),
|
|
Self::MissingIssuerNpcName => f.write_str("quest_record.issuer_npc_name 不能为空"),
|
|
Self::MissingTitle => f.write_str("quest_record.title 不能为空"),
|
|
Self::MissingDescription => f.write_str("quest_record.description 不能为空"),
|
|
Self::MissingRewardText => f.write_str("quest_record.reward_text 不能为空"),
|
|
Self::EmptySteps => f.write_str("quest_record.steps 至少需要一条 step"),
|
|
Self::MissingStepId => f.write_str("quest_step.step_id 不能为空"),
|
|
Self::MissingStepTitle => f.write_str("quest_step.title 不能为空"),
|
|
Self::MissingStepRevealText => f.write_str("quest_step.reveal_text 不能为空"),
|
|
Self::MissingStepCompleteText => f.write_str("quest_step.complete_text 不能为空"),
|
|
Self::QuestNotReadyToTurnIn => f.write_str("当前任务还没有进入可交付状态"),
|
|
Self::MissingRewardItemId => f.write_str("quest_reward.items[].item_id 不能为空"),
|
|
Self::MissingRewardItemCategory => {
|
|
f.write_str("quest_reward.items[].category 不能为空")
|
|
}
|
|
Self::MissingRewardItemName => f.write_str("quest_reward.items[].name 不能为空"),
|
|
Self::InvalidRewardItemQuantity => {
|
|
f.write_str("quest_reward.items[].quantity 必须大于 0")
|
|
}
|
|
Self::MissingRewardItemStackKey => {
|
|
f.write_str("quest_reward.items[].stack_key 不能为空")
|
|
}
|
|
Self::RewardEquipmentItemCannotStack => {
|
|
f.write_str("quest_reward.items[] 可装备物品不能标记为 stackable")
|
|
}
|
|
Self::RewardNonStackableItemMustStaySingleQuantity => {
|
|
f.write_str("quest_reward.items[] 不可堆叠物品必须固定为单槽位单数量")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Error for QuestRecordFieldError {}
|