lyon_tessellation/
error.rs1pub type TessellationResult = Result<(), TessellationError>;
3
4#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
6pub enum GeometryBuilderError {
7 InvalidVertex,
8 TooManyVertices,
9}
10
11#[cfg(feature = "std")]
12impl core::fmt::Display for GeometryBuilderError {
13 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
14 match self {
15 GeometryBuilderError::InvalidVertex => {
16 std::write!(f, "Invalid vertex")
17 },
18 GeometryBuilderError::TooManyVertices => {
19 std::write!(f, "Too many vertices")
20 }
21 }
22 }
23}
24
25#[cfg(feature = "std")]
26impl std::error::Error for GeometryBuilderError {}
27
28#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
33pub enum InternalError {
34 IncorrectActiveEdgeOrder(i16),
35 InsufficientNumberOfSpans,
36 InsufficientNumberOfEdges,
37 MergeVertexOutside,
38 InvalidNumberOfEdgesBelowVertex,
39 ErrorCode(i16),
40}
41
42#[cfg(feature = "std")]
43impl core::fmt::Display for InternalError {
44 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
45 match self {
46 InternalError::IncorrectActiveEdgeOrder(i) => {
47 std::write!(f, "Incorrect active edge order ({i})")
48 },
49 InternalError::InsufficientNumberOfSpans => {
50 std::write!(f, "Insufficient number of spans")
51 },
52 InternalError::InsufficientNumberOfEdges => {
53 std::write!(f, "Insufficient number of edges")
54 },
55 InternalError::MergeVertexOutside => {
56 std::write!(f, "Merge vertex is outside of the shape")
57 },
58 InternalError::InvalidNumberOfEdgesBelowVertex => {
59 std::write!(f, "Unexpected number of edges below a vertex")
60 },
61 InternalError::ErrorCode(i) => {
62 std::write!(f, "Error code: #{i}")
63 },
64 }
65 }
66}
67
68#[cfg(feature = "std")]
69impl std::error::Error for InternalError {}
70
71#[derive(Clone, Debug, PartialEq)]
73pub enum TessellationError {
74 UnsupportedParamater(UnsupportedParamater),
76 GeometryBuilder(GeometryBuilderError),
77 Internal(InternalError),
78}
79
80#[cfg(feature = "std")]
81impl core::fmt::Display for TessellationError {
82 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
83 match self {
84 TessellationError::UnsupportedParamater(e) => {
85 std::write!(f, "Unsupported parameter: {e}")
86 },
87 TessellationError::GeometryBuilder(e) => {
88 std::write!(f, "Geometry builder error: {e}")
89 },
90 TessellationError::Internal(e) => {
91 std::write!(f, "Internal error: {e}")
92 },
93 }
94 }
95}
96
97#[cfg(feature = "std")]
98impl std::error::Error for TessellationError {}
99
100impl core::convert::From<GeometryBuilderError> for TessellationError {
101 fn from(value: GeometryBuilderError) -> Self {
102 Self::GeometryBuilder(value)
103 }
104}
105
106impl core::convert::From<InternalError> for TessellationError {
107 fn from(value: InternalError) -> Self {
108 Self::Internal(value)
109 }
110}
111
112#[derive(Clone, Debug, PartialEq)]
113pub enum UnsupportedParamater {
114 PositionIsNaN,
115 ToleranceIsNaN,
116}
117
118#[cfg(feature = "std")]
119impl core::fmt::Display for UnsupportedParamater {
120 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
121 match self {
122 UnsupportedParamater::PositionIsNaN => {
123 std::write!(f, "Position is not a number")
124 },
125 UnsupportedParamater::ToleranceIsNaN => {
126 std::write!(f, "Tolerance threshold is not a number")
127 },
128 }
129 }
130}
131
132#[cfg(feature = "std")]
133impl std::error::Error for UnsupportedParamater {}