Skip to content

Commit 3bb8029

Browse files
committed
Refactor error handling in matrix projection functions to use log_and_throw_error for consistency
1 parent 6987872 commit 3bb8029

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/ipc/dynamics/rigid/simulator.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ void Simulator::step()
9797
grad_norm, hess.norm(), alpha);
9898
} while (dx > m_time_integrator->dt * 1e-3 && ++iter < 100);
9999
logger().info(
100-
"converged: iter={} dx={:g} norm(grad)={:g} norm(hess)={:g}", iter, dx,
101-
grad_norm);
100+
"converged: iter={} dx={:g} norm(grad)={:g}", iter, dx, grad_norm);
102101

103102
for (size_t i = 0; i < m_bodies->num_bodies(); ++i) {
104103
poses[i].position = x.segment<3>(6 * i);

src/ipc/utils/eigen_ext.tpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ project_to_pd(
3131
Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>>
3232
eigensolver(A);
3333
if (eigensolver.info() != Eigen::Success) {
34-
logger().error("unable to project matrix onto positive definite cone");
35-
throw std::runtime_error(
34+
log_and_throw_error(
3635
"unable to project matrix onto positive definite cone");
3736
}
3837
// Check if all eigen values are positive.
@@ -76,10 +75,8 @@ project_to_psd(
7675
Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>>
7776
eigensolver(A);
7877
if (eigensolver.info() != Eigen::Success) {
79-
logger().error(
78+
log_and_throw_error(
8079
"unable to project matrix onto positive semi-definite cone");
81-
throw std::runtime_error(
82-
"unable to project matrix onto positive definite cone");
8380
}
8481
// Check if all eigen values are zero or positive.
8582
// The eigenvalues are sorted in increasing order.

0 commit comments

Comments
 (0)