truck_modeling/
errors.rs

1use thiserror::Error;
2
3/// Modeling errors
4#[derive(Debug, PartialEq, Eq, Error)]
5pub enum Error {
6    /// wrapper of topological error
7    #[error(transparent)]
8    FromTopology(#[from] truck_topology::errors::Error),
9    /// tried to attach a plane to a wire that was not on one plane.
10    /// cf. [`builder::try_attach_plane`](../builder/fn.try_attach_plane.html)
11    #[error("cannot attach a plane to a wire that is not on one plane.")]
12    WireNotInOnePlane,
13    /// tried to create homotopy for two wires with different numbers of edges.
14    /// cf. [`builder::try_wire_homotopy`](../builder/fn.try_wire_homotopy.html)
15    #[error("The wires must contain the same number of edges to create a homotopy.")]
16    NotSameNumberOfEdges,
17}
18
19#[test]
20fn print_messages() {
21    use std::io::Write;
22    writeln!(
23        &mut std::io::stderr(),
24        "****** test of the expressions of error messages ******\n"
25    )
26    .unwrap();
27    writeln!(
28        &mut std::io::stderr(),
29        "{}\n",
30        Error::FromTopology(truck_topology::errors::Error::SameVertex)
31    )
32    .unwrap();
33    writeln!(&mut std::io::stderr(), "{}\n", Error::WireNotInOnePlane).unwrap();
34    writeln!(
35        &mut std::io::stderr(),
36        "*******************************************************"
37    )
38    .unwrap();
39}