axiolid_contracts/error.rs
1//! Structured geometry failures suitable for fallback and diagnostics.
2
3use thiserror::Error;
4
5use crate::{BackendId, Operation};
6
7/// Result alias for geometry operations.
8pub type GeomResult<T> = Result<T, GeomError>;
9
10/// Why a backend-neutral geometry operation failed.
11#[non_exhaustive]
12#[derive(Debug, Clone, Error, PartialEq, Eq)]
13pub enum GeomError {
14 /// Input violates the operation's structural preconditions.
15 #[error("invalid geometry input: {0}")]
16 InvalidInput(String),
17 /// Backend cannot implement this capability.
18 #[error("backend `{backend}` does not support {operation:?}")]
19 Unsupported {
20 /// Backend.
21 backend: BackendId,
22 /// Missing capability.
23 operation: Operation,
24 },
25 /// Backend supports the operation but not this input family.
26 #[error("backend `{backend}` cannot apply {operation:?} to `{input}`")]
27 UnsupportedInput {
28 /// Backend.
29 backend: BackendId,
30 /// Requested operation.
31 operation: Operation,
32 /// Stable, human-readable input family.
33 input: &'static str,
34 },
35 /// Backend exists but its hardware/runtime is unavailable.
36 #[error("backend `{backend}` is unavailable: {reason}")]
37 Unavailable {
38 /// Backend.
39 backend: BackendId,
40 /// Diagnostic reason.
41 reason: String,
42 },
43 /// Backend returned a result that violates its operation contract.
44 #[error("backend `{backend}` violated its contract: {detail}")]
45 BackendContractViolation {
46 /// Backend that violated the contract.
47 backend: BackendId,
48 /// Actionable contract diagnostic.
49 detail: String,
50 },
51 /// Dirty topology violates a manifold precondition.
52 #[error("input is not manifold: {0}")]
53 NotManifold(String),
54 /// Numerical configuration could not be resolved reliably.
55 #[error("numerically degenerate input: {0}")]
56 Degenerate(String),
57 /// Explicit operation budget was exceeded.
58 #[error("operation exceeded its {resource} budget")]
59 BudgetExceeded {
60 /// Resource name, e.g. memory or iterations.
61 resource: &'static str,
62 },
63 /// Cooperative cancellation.
64 #[error("operation cancelled")]
65 Cancelled,
66}