Skip to content

Commit 6dc65d8

Browse files
committed
update API on error
1 parent a16d445 commit 6dc65d8

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Clarabel.rs

Submodule Clarabel.rs updated 55 files

rust_wrapper/src/solver/implementations/default/solver.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,16 @@ unsafe fn _internal_DefaultSolver_new<T: FloatT>(
9393
forget(q);
9494
forget(b);
9595

96-
// Return the solver object as an opaque pointer to C.
97-
// The solver object is boxed and left on the heap.
98-
Box::into_raw(Box::new(solver)) as *mut c_void
96+
// Solver should be a Result<DefaultSolver<T>, SolverError>
97+
match solver {
98+
Ok(solver) => Box::into_raw(Box::new(solver)) as *mut c_void,
99+
Err(e) => {
100+
// Just print an error here and return a null pointer
101+
// This could surely done in a more graceful way
102+
println!("Error creating DefaultSolver: {:?}", e);
103+
std::ptr::null_mut()
104+
}
105+
}
99106
}
100107

101108
#[no_mangle]

0 commit comments

Comments
 (0)