Integrate unfinished server-rs refactor worklists
This commit is contained in:
@@ -1,3 +1,107 @@
|
||||
//! 运行时领域错误过渡落位。
|
||||
//!
|
||||
//! 错误保持运行时业务语义,例如快照版本非法、兑换码不可用或钱包余额不足。
|
||||
|
||||
use crate::MAX_BROWSE_HISTORY_BATCH_SIZE;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum RuntimeSettingsFieldError {
|
||||
MissingUserId,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for RuntimeSettingsFieldError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::MissingUserId => f.write_str("runtime_setting.user_id 不能为空"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum RuntimeBrowseHistoryFieldError {
|
||||
MissingUserId,
|
||||
TooManyEntries,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for RuntimeBrowseHistoryFieldError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::MissingUserId => f.write_str("browse_history.user_id 不能为空"),
|
||||
Self::TooManyEntries => write!(
|
||||
f,
|
||||
"browse_history.entries 单次最多只允许 {} 条",
|
||||
MAX_BROWSE_HISTORY_BATCH_SIZE
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum RuntimeProfileFieldError {
|
||||
MissingUserId,
|
||||
MissingLedgerId,
|
||||
InvalidWalletAmount,
|
||||
WalletAmountOverflow,
|
||||
WalletBalanceOverflow,
|
||||
InsufficientWalletBalance,
|
||||
MissingInviteCode,
|
||||
MissingRedeemCode,
|
||||
RedeemCodeDisabled,
|
||||
RedeemCodeUsesExhausted,
|
||||
RedeemCodeNotAllowedForUser,
|
||||
InvalidRedeemCodeReward,
|
||||
InvalidRedeemCodeMaxUses,
|
||||
MissingProductId,
|
||||
MissingWorldKey,
|
||||
MissingBottomTab,
|
||||
MissingCheckpointSessionId,
|
||||
UnknownRechargeProduct,
|
||||
InvalidGameStateJson,
|
||||
InvalidCurrentStoryJson,
|
||||
MissingRuntimeSessionId,
|
||||
RuntimeSessionMismatch {
|
||||
expected_session_id: String,
|
||||
actual_session_id: String,
|
||||
},
|
||||
NonPersistentRuntimeSnapshot,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for RuntimeProfileFieldError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::MissingUserId => f.write_str("profile.user_id 不能为空"),
|
||||
Self::MissingLedgerId => f.write_str("profile.wallet_ledger_id 不能为空"),
|
||||
Self::InvalidWalletAmount => f.write_str("profile.wallet_amount 必须大于 0"),
|
||||
Self::WalletAmountOverflow => f.write_str("profile.wallet_amount 超出上限"),
|
||||
Self::WalletBalanceOverflow => f.write_str("profile.wallet_balance 超出上限"),
|
||||
Self::InsufficientWalletBalance => f.write_str("叙世币余额不足"),
|
||||
Self::MissingInviteCode => f.write_str("referral.invite_code 不能为空"),
|
||||
Self::MissingRedeemCode => f.write_str("兑换码不能为空"),
|
||||
Self::RedeemCodeDisabled => f.write_str("兑换码已停用"),
|
||||
Self::RedeemCodeUsesExhausted => f.write_str("兑换次数已用完"),
|
||||
Self::RedeemCodeNotAllowedForUser => f.write_str("该兑换码不适用于当前账号"),
|
||||
Self::InvalidRedeemCodeReward => f.write_str("兑换码奖励无效"),
|
||||
Self::InvalidRedeemCodeMaxUses => f.write_str("兑换次数必须大于 0"),
|
||||
Self::MissingProductId => f.write_str("recharge.product_id 不能为空"),
|
||||
Self::MissingWorldKey => f.write_str("profile.world_key 不能为空"),
|
||||
Self::MissingBottomTab => f.write_str("runtime_snapshot.bottom_tab 不能为空"),
|
||||
Self::MissingCheckpointSessionId => f.write_str("checkpoint.session_id 不能为空"),
|
||||
Self::UnknownRechargeProduct => f.write_str("recharge.product_id 不存在"),
|
||||
Self::InvalidGameStateJson => {
|
||||
f.write_str("runtime_snapshot.game_state 必须是合法 JSON")
|
||||
}
|
||||
Self::InvalidCurrentStoryJson => {
|
||||
f.write_str("runtime_snapshot.current_story 必须是合法 JSON object 或 null")
|
||||
}
|
||||
Self::MissingRuntimeSessionId => {
|
||||
f.write_str("服务端运行时快照缺少 runtimeSessionId,无法创建 checkpoint")
|
||||
}
|
||||
Self::RuntimeSessionMismatch { .. } => {
|
||||
f.write_str("checkpoint sessionId 与服务端运行时快照不一致")
|
||||
}
|
||||
Self::NonPersistentRuntimeSnapshot => {
|
||||
f.write_str("预览或测试运行态不能创建正式 checkpoint")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user