Skip to content

Commit 6e5aed1

Browse files
committed
error handling
1 parent e211fcb commit 6e5aed1

4 files changed

Lines changed: 50 additions & 14 deletions

File tree

‎src/bivariate/quad_over_lin.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
#include "utils/CSC_Matrix.h"
44
#include <assert.h>
55
#include <math.h>
6+
#include <stdio.h>
67
#include <stdlib.h>
8+
#include <string.h>
79

810
// ------------------------------------------------------------------------------
911
// Implementation of quad-over-lin. The second argument will always be a variable
@@ -231,7 +233,9 @@ static void wsum_hess_init(expr *node)
231233
else
232234
{
233235
/* TODO: implement */
234-
assert(false && "not implemented");
236+
fprintf(stderr, "Error in quad_over_lin wsum_hess_init: non-variable child "
237+
"not implemented\n");
238+
exit(1);
235239
}
236240
}
237241

@@ -288,7 +292,9 @@ static void eval_wsum_hess(expr *node, const double *w)
288292
else
289293
{
290294
/* TODO: implement */
291-
assert(false && "not implemented");
295+
fprintf(stderr, "Error in quad_over_lin eval_wsum_hess: non-variable child "
296+
"not implemented\n");
297+
exit(1);
292298
}
293299
}
294300

‎src/other/prod.c‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "other.h"
22
#include <assert.h>
33
#include <math.h>
4+
#include <stdio.h>
45
#include <stdlib.h>
56
#include <string.h>
67

@@ -62,7 +63,9 @@ static void jacobian_init(expr *node)
6263
}
6364
else
6465
{
65-
assert(false && "not implemented");
66+
fprintf(stderr,
67+
"Error in prod jacobian_init: non-variable child not implemented\n");
68+
exit(1);
6669
}
6770
}
6871

@@ -94,7 +97,9 @@ static void eval_jacobian(expr *node)
9497
}
9598
else
9699
{
97-
assert(false && "not implemented");
100+
fprintf(stderr,
101+
"Error in prod eval_jacobian: non-variable child not implemented\n");
102+
exit(1);
98103
}
99104
}
100105

@@ -133,7 +138,10 @@ static void wsum_hess_init(expr *node)
133138
}
134139
else
135140
{
136-
assert(false && "not implemented");
141+
fprintf(
142+
stderr,
143+
"Error in prod wsum_hess_init: non-variable child not implemented\n");
144+
exit(1);
137145
}
138146
}
139147

@@ -164,7 +172,10 @@ static void eval_wsum_hess(expr *node, const double *w)
164172
}
165173
else
166174
{
167-
assert(false && "not implemented");
175+
fprintf(
176+
stderr,
177+
"Error in prod eval_wsum_hess: non-variable child not implemented\n");
178+
exit(1);
168179
}
169180
}
170181

‎src/other/prod_axis_one.c‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ static void jacobian_init(expr *node)
8484
}
8585
else
8686
{
87-
assert(false && "child must be a variable");
87+
fprintf(stderr,
88+
"Error in prod_axis_one jacobian_init: child must be a variable\n");
89+
exit(1);
8890
}
8991
}
9092

@@ -125,7 +127,9 @@ static void eval_jacobian(expr *node)
125127
}
126128
else
127129
{
128-
assert(false && "child must be a variable");
130+
fprintf(stderr,
131+
"Error in prod_axis_one eval_jacobian: child must be a variable\n");
132+
exit(1);
129133
}
130134
}
131135

@@ -173,7 +177,9 @@ static void wsum_hess_init(expr *node)
173177
}
174178
else
175179
{
176-
assert(false && "child must be a variable");
180+
fprintf(stderr,
181+
"Error in prod_axis_one wsum_hess_init: child must be a variable\n");
182+
exit(1);
177183
}
178184
}
179185

@@ -350,7 +356,9 @@ static void eval_wsum_hess(expr *node, const double *w)
350356
}
351357
else
352358
{
353-
assert(false && "child must be a variable");
359+
fprintf(stderr,
360+
"Error in prod_axis_one eval_wsum_hess: child must be a variable\n");
361+
exit(1);
354362
}
355363
}
356364

‎src/other/prod_axis_zero.c‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "other.h"
22
#include <assert.h>
33
#include <math.h>
4+
#include <stdio.h>
45
#include <stdlib.h>
56
#include <string.h>
67

@@ -78,7 +79,9 @@ static void jacobian_init(expr *node)
7879
}
7980
else
8081
{
81-
assert(false && "child must be a variable");
82+
fprintf(stderr,
83+
"Error in prod_axis_zero jacobian_init: child must be a variable\n");
84+
exit(1);
8285
}
8386
}
8487

@@ -118,7 +121,9 @@ static void eval_jacobian(expr *node)
118121
}
119122
else
120123
{
121-
assert(false && "child must be a variable");
124+
fprintf(stderr,
125+
"Error in prod_axis_zero eval_jacobian: child must be a variable\n");
126+
exit(1);
122127
}
123128
}
124129

@@ -164,7 +169,10 @@ static void wsum_hess_init(expr *node)
164169
}
165170
else
166171
{
167-
assert(false && "child must be a variable");
172+
fprintf(
173+
stderr,
174+
"Error in prod_axis_zero wsum_hess_init: child must be a variable\n");
175+
exit(1);
168176
}
169177
}
170178

@@ -306,7 +314,10 @@ static void eval_wsum_hess(expr *node, const double *w)
306314
}
307315
else
308316
{
309-
assert(false && "child must be a variable");
317+
fprintf(
318+
stderr,
319+
"Error in prod_axis_zero eval_wsum_hess: child must be a variable\n");
320+
exit(1);
310321
}
311322
}
312323

0 commit comments

Comments
 (0)