1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! The crate's [`Error`] type.
use core::fmt;
use crate::geom::Point;
/// Why an operation failed.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum Error {
/// A coordinate lies outside `[-MAX_COORD, MAX_COORD]`
/// ([`MAX_COORD`](crate::MAX_COORD)).
CoordinateOutOfRange(Point),
/// An obstacle id does not name a live obstacle.
UnknownObstacle,
/// A port id does not name a live port.
UnknownPort,
/// A port lies in the open interior of an obstacle, so no route can reach it.
PortBlocked(Point),
/// A port allows no direction.
PortWithoutDirections(Point),
/// No route exists between the two ports of a connector.
NoRoute {
/// The index of the connector in the request.
connector: usize,
},
/// A cost product or sum does not fit into `u64`.
CostOverflow,
/// A net needs at least two ports.
TooFewPorts,
/// Two obstacle interiors overlap, which the triangulation-based routers do not
/// support.
OverlappingObstacles,
/// The constrained Delaunay triangulation could not recover a constraint. Only
/// crossing constraints cause this, which validated input rules out.
TriangulationFailed,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::CoordinateOutOfRange(p) => write!(f, "coordinate out of range at {p}"),
Self::UnknownObstacle => f.write_str("unknown obstacle id"),
Self::UnknownPort => f.write_str("unknown port id"),
Self::PortBlocked(p) => write!(f, "port {p} lies inside an obstacle"),
Self::PortWithoutDirections(p) => write!(f, "port {p} allows no direction"),
Self::NoRoute { connector } => write!(f, "no route for connector {connector}"),
Self::CostOverflow => f.write_str("route cost overflows u64"),
Self::TooFewPorts => f.write_str("a net needs at least two ports"),
Self::OverlappingObstacles => f.write_str("obstacle interiors overlap"),
Self::TriangulationFailed => f.write_str("constraint recovery failed"),
}
}
}
impl core::error::Error for Error {}