smooth_frame/errors/
mod.rs1use std::error::Error;
2use std::fmt;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub enum SmoothError {
7 NonFiniteInput,
9 NegativeInput,
11 DegenerateAxis,
13 InvalidAngle,
15 TooFewPoints,
17 DegenerateFrame,
19 ConcaveFrame,
21 SelfIntersectingFrame,
23}
24
25impl fmt::Display for SmoothError {
26 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28 match self {
29 SmoothError::NonFiniteInput => write!(f, "输入包含非有限数值"),
30 SmoothError::NegativeInput => write!(f, "长度、半径或限制不能为负数"),
31 SmoothError::DegenerateAxis => write!(f, "角点方向向量退化"),
32 SmoothError::InvalidAngle => write!(f, "角点角度必须满足 0 < phi < PI"),
33 SmoothError::TooFewPoints => write!(f, "闭合 frame 至少需要 3 个点"),
34 SmoothError::DegenerateFrame => write!(f, "frame 包含退化边或面积为零"),
35 SmoothError::ConcaveFrame => write!(f, "当前版本仅支持凸 frame"),
36 SmoothError::SelfIntersectingFrame => write!(f, "当前版本不支持自相交 frame"),
37 }
38 }
39}
40
41impl Error for SmoothError {}