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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
use std::error::Error;
use std::fmt;
use std::fmt::Display;
#[derive(Debug)]
pub enum GmshError {
Initialization,
Execution,
CInterface,
ModelMutation,
ModelLookup,
ModelBadInput,
ModelParallelMeshQuery,
UnknownOption,
UnknownError,
}
pub type GmshResult<T> = Result<T, GmshError>;
impl Display for GmshError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
GmshError::Initialization => write!(
f,
"initialization error for Gmsh or an associated library is missing"
),
_ => write!(f, "big ol error"),
}
}
}
impl Error for GmshError {}
#[doc(hidden)]
#[macro_export]
macro_rules! check_main_error {
($ierr:expr, $return_val: expr) => {
match $ierr {
0 => Ok($return_val),
-1 => Err(GmshError::Initialization),
1 => Err(GmshError::Execution),
_ => Err(GmshError::UnknownError),
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! check_model_error {
($ierr:expr, $return_val: expr) => {
match $ierr {
0 => Ok($return_val),
-1 => Err(GmshError::Initialization),
1 => Err(GmshError::ModelMutation),
2 => Err(GmshError::ModelLookup),
3 => Err(GmshError::ModelBadInput),
4 => Err(GmshError::ModelParallelMeshQuery),
_ => Err(GmshError::UnknownError),
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! check_option_error {
($ierr:expr, $return_val: expr) => {
match $ierr {
0 => Ok($return_val),
-1 => Err(GmshError::Initialization),
1 => Err(GmshError::UnknownOption),
_ => Err(GmshError::UnknownError),
}
};
}