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
57
use std::error::Error;
use std::fmt;
#[derive(Debug)]
pub enum SphericalCowError {
NegativeRadius,
NegativeExtents,
Uncontained,
NoneSetF,
NoneFront,
}
impl fmt::Display for SphericalCowError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
SphericalCowError::NegativeRadius => write!(f, "Supplied radius is negative."),
SphericalCowError::NegativeExtents => write!(f, "A supplied half extent is negative."),
SphericalCowError::Uncontained => {
write!(f, "Sphere is not contained within bounding geometry.")
}
SphericalCowError::NoneSetF => {
write!(f, "Returned none when choosing value from set f")
}
SphericalCowError::NoneFront => {
write!(f, "Returned none when choosing value from front")
}
}
}
}
impl Error for SphericalCowError {
fn description(&self) -> &str {
match *self {
SphericalCowError::NegativeRadius => "negative radius",
SphericalCowError::NegativeExtents => "negative half extent",
SphericalCowError::Uncontained => "outside bounding geometry",
SphericalCowError::NoneSetF => "none from set f",
SphericalCowError::NoneFront => "none from front",
}
}
}