Preserve partial creation replies on stream failure
Some checks failed
CI / verify (push) Has been cancelled
Some checks failed
CI / verify (push) Has been cancelled
This commit is contained in:
37
server-rs/crates/module-square-hole/src/errors.rs
Normal file
37
server-rs/crates/module-square-hole/src/errors.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
use std::fmt::{self, Display};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum SquareHoleError {
|
||||
MissingText,
|
||||
MissingOwnerUserId,
|
||||
InvalidShapeCount,
|
||||
InvalidDifficulty,
|
||||
MissingProfileId,
|
||||
MissingRunId,
|
||||
MissingHoleId,
|
||||
RunNotActive,
|
||||
SnapshotVersionMismatch,
|
||||
HoleNotFound,
|
||||
Incompatible,
|
||||
}
|
||||
|
||||
impl Display for SquareHoleError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let message = match self {
|
||||
Self::MissingText => "文本不能为空",
|
||||
Self::MissingOwnerUserId => "owner_user_id 缺失",
|
||||
Self::InvalidShapeCount => "形状数量必须在 6 到 24 之间",
|
||||
Self::InvalidDifficulty => "难度必须在 1 到 10 之间",
|
||||
Self::MissingProfileId => "缺少 profileId",
|
||||
Self::MissingRunId => "缺少 runId",
|
||||
Self::MissingHoleId => "缺少 holeId",
|
||||
Self::RunNotActive => "当前运行态未激活",
|
||||
Self::SnapshotVersionMismatch => "快照版本不一致",
|
||||
Self::HoleNotFound => "洞口不存在",
|
||||
Self::Incompatible => "当前形状不能投入这个洞口",
|
||||
};
|
||||
write!(f, "{message}")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for SquareHoleError {}
|
||||
Reference in New Issue
Block a user