epanet_rs/ffi/
error_codes.rs1use strum::FromRepr;
4use thiserror::Error;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Error, FromRepr)]
13#[repr(i32)]
14pub enum ErrorCode {
15 #[error("Invalid Project Handle")]
16 InvalidHandle = -1,
17
18 #[error("No error")]
19 Ok = 0,
20
21 #[error("Insufficient memory available")]
23 InsufficientMemory = 101,
24 #[error("No network data available")]
25 NoNetworkData = 102,
26 #[error("Hydraulic solver not opened")]
27 HydraulicSolverNotOpened = 103,
28 #[error("No hydraulics for water quality analysis")]
29 NoHydraulicsForQuality = 104,
30 #[error("Water quality solver not opened")]
31 QualitySolverNotOpened = 105,
32 #[error("No results saved to report on")]
33 NoResultsSaved = 106,
34 #[error("Hydraulics supplied from external file")]
35 HydraulicsFromExternalFile = 107,
36 #[error("Cannot use external file while hydraulics solver is open")]
37 ExternalFileConflict = 108,
38 #[error("Cannot solve network hydraulic equations")]
39 CannotSolveHydraulics = 110,
40 #[error("Cannot solve water quality transport equations")]
41 CannotSolveQuality = 120,
42
43 #[error("One or more errors in an input file")]
45 InputError = 200,
46 #[error("Syntax error")]
47 SyntaxError = 201,
48 #[error("Function call contains an illegal numeric value")]
49 IllegalNumericValue = 202,
50 #[error("Function call refers to an undefined node")]
51 UndefinedNode = 203,
52 #[error("Function call refers to an undefined link")]
53 UndefinedLink = 204,
54 #[error("Function call refers to an undefined time pattern")]
55 UndefinedPattern = 205,
56 #[error("Function call refers to an undefined curve")]
57 UndefinedCurve = 206,
58 #[error("Function call attempts to control a check valve pipe or a GPV valve")]
59 IllegalValveControl = 207,
60 #[error("Function call contains illegal PDA pressure limits")]
61 IllegalPdaPressureLimits = 208,
62 #[error("Function call contains an illegal node property value")]
63 IllegalNodeProperty = 209,
64 #[error("Function call contains an illegal link property value")]
65 IllegalLinkProperty = 211,
66 #[error("Function call refers to an undefined Trace Node")]
67 UndefinedTraceNode = 212,
68 #[error("Function call contains an invalid option value")]
69 InvalidOptionValue = 213,
70 #[error("Too many characters in a line of an input file")]
71 LineTooLong = 214,
72 #[error("Function call contains a duplicate ID label")]
73 DuplicateId = 215,
74 #[error("Function call refers to an undefined pump")]
75 UndefinedPump = 216,
76 #[error("Invalid pump energy data")]
77 InvalidPumpEnergyData = 217,
78 #[error("Illegal valve connection to tank node")]
79 IllegalValveToTank = 219,
80 #[error("Illegal valve connection to another valve")]
81 IllegalValveToValve = 220,
82 #[error("Mis-placed clause in rule-based control")]
83 MisplacedRuleClause = 221,
84 #[error("Link assigned same start and end nodes")]
85 LinkSameStartEnd = 222,
86 #[error("Not enough nodes in network")]
87 NotEnoughNodes = 223,
88 #[error("No tanks or reservoirs in network")]
89 NoTanksOrReservoirs = 224,
90 #[error("Invalid lower/upper levels for tank")]
91 InvalidTankLevels = 225,
92 #[error("No head curve or power rating for pump")]
93 NoPumpCurveOrPower = 226,
94 #[error("Invalid head curve for pump")]
95 InvalidPumpCurve = 227,
96 #[error("Nonincreasing x-values for curve")]
97 NonincreasingCurveX = 230,
98 #[error("No data provided for a curve")]
99 NoCurveData = 231,
100 #[error("No data provided for a pattern")]
101 NoPatternData = 232,
102 #[error("Network has unconnected nodes")]
103 UnconnectedNodes = 233,
104 #[error("Function call refers to nonexistent water quality source")]
105 NonexistentQualitySource = 240,
106 #[error("Function call refers to nonexistent control")]
107 NonexistentControl = 241,
108 #[error("Function call contains invalid format")]
109 InvalidFormat = 250,
110 #[error("Function call contains invalid parameter code")]
111 InvalidParameterCode = 251,
112 #[error("Function call refers to an invalid ID name")]
113 InvalidIdName = 252,
114 #[error("Function call refers to nonexistent demand category")]
115 NonexistentDemandCategory = 253,
116 #[error("Function call refers to node with no coordinates")]
117 NodeNoCoordinates = 254,
118 #[error("Function call refers to link with no vertices")]
119 LinkNoVertices = 255,
120 #[error("Function call refers to nonexistent rule")]
121 NonexistentRule = 257,
122 #[error("Function call refers to nonexistent rule clause")]
123 NonexistentRuleClause = 258,
124 #[error("Function call attempts to delete a node that still has links connected to it")]
125 DeleteNodeWithLinks = 259,
126 #[error("Function call attempts to delete node assigned as a Trace Node")]
127 DeleteTraceNode = 260,
128 #[error("Function call attempts to delete a node or link contained in a control")]
129 DeleteNodeOrLinkInControl = 261,
130 #[error("Function call attempts to modify network structure while a solver is open")]
131 ModifyWhileSolverOpen = 262,
132 #[error("Function call refers to node that is not a tank")]
133 NotATank = 263,
134 #[error("Function call refers to a link that is not a valve")]
135 NotAValve = 264,
136 #[error("An invalid section keyword was detected in an input file")]
137 InvalidSectionKeyword = 299,
138
139 #[error("Identical file names used for different types of files")]
141 IdenticalFileNames = 301,
142 #[error("Cannot open input file")]
143 CannotOpenInputFile = 302,
144 #[error("Cannot open report file")]
145 CannotOpenReportFile = 303,
146 #[error("Cannot open output file")]
147 CannotOpenOutputFile = 304,
148 #[error("Cannot open hydraulics file")]
149 CannotOpenHydraulicsFile = 305,
150 #[error("Hydraulics file does not match network data")]
151 HydraulicsFileMismatch = 306,
152 #[error("Cannot read hydraulics file")]
153 CannotReadHydraulicsFile = 307,
154 #[error("Cannot save results to binary file")]
155 CannotSaveBinaryResults = 308,
156 #[error("Cannot save results to report file")]
157 CannotSaveReportResults = 309,
158}