honeycomb_core/cmap/
error.rs

1//! Main error type
2
3use crate::{attributes::AttributeError, cmap::DartIdType};
4
5/// Dart allocation error struct
6#[derive(Debug, thiserror::Error, PartialEq, Eq)]
7#[error("cannot reserve {0} darts: not enough unused darts")]
8pub struct DartReservationError(pub usize);
9
10/// Dart freeing error struct
11#[derive(Debug, thiserror::Error, PartialEq, Eq)]
12#[error("cannot set dart {0} as unused: dart isn't free")]
13pub struct DartReleaseError(pub DartIdType);
14
15/// Link operation error enum
16#[derive(Debug, thiserror::Error, PartialEq, Eq)]
17pub enum LinkError {
18    /// The base dart is not free.
19    #[error("cannot link {1} to {2}: b{0}({1}) != NULL")]
20    NonFreeBase(u8, DartIdType, DartIdType),
21    /// The image dart is not free
22    #[error("cannot link {1} to {2}: b{0}({2}) != NULL")]
23    NonFreeImage(u8, DartIdType, DartIdType),
24    /// The dart is already free.
25    #[error("cannot unlink {1}: b{0}({1}) == NULL")]
26    AlreadyFree(u8, DartIdType),
27    /// The two orbits being linked have different structures.
28    #[error("cannot 3-link {0} and {1}: faces do not have the same structure")]
29    AsymmetricalFaces(DartIdType, DartIdType),
30}
31
32/// Sew operation error enum
33#[derive(Debug, thiserror::Error, PartialEq, Eq)]
34pub enum SewError {
35    /// Geometry predicate failed verification.
36    #[error("cannot {0}-sew darts {1} and {2} due to geometry predicates")]
37    BadGeometry(u8, DartIdType, DartIdType),
38    /// Dart link failed.
39    #[error("inner link failed: {0}")]
40    FailedLink(#[from] LinkError),
41    /// Attribute operation failed.
42    #[error("attribute operation failed: {0}")]
43    FailedAttributeOp(#[from] AttributeError),
44}