Better error checking and reporting for linear solvers.

A lot of error checking cruft has accumulated over the years
in the various linear solvers. This change makes the error reporting
more robust and consistent across the various solvers.

Preconditioners are not covered by this change and will be the
subject of a future change.

Change-Id: Ibeb2572a1e67758953dde8d12e3abc6d1df9052d
diff --git a/internal/ceres/visibility_based_preconditioner.cc b/internal/ceres/visibility_based_preconditioner.cc
index aeaab12..e0737f2 100644
--- a/internal/ceres/visibility_based_preconditioner.cc
+++ b/internal/ceres/visibility_based_preconditioner.cc
@@ -435,14 +435,19 @@
   // matrix contains the values.
   lhs->stype = 1;
 
+  // TODO(sameeragarwal): Refactor to pipe this up and out.
+  string status;
+
   // Symbolic factorization is computed if we don't already have one handy.
   if (factor_ == NULL) {
-    factor_ = ss_.BlockAnalyzeCholesky(lhs, block_size_, block_size_);
+    factor_ = ss_.BlockAnalyzeCholesky(lhs, block_size_, block_size_, &status);
   }
 
-  LinearSolverTerminationType status = ss_.Cholesky(lhs, factor_);
+  const LinearSolverTerminationType termination_type =
+      (factor_ != NULL) ? ss_.Cholesky(lhs, factor_, &status) : FATAL_ERROR;
+
   ss_.Free(lhs);
-  return status;
+  return termination_type;
 }
 
 void VisibilityBasedPreconditioner::RightMultiply(const double* x,
@@ -453,7 +458,9 @@
 
   const int num_rows = m_->num_rows();
   memcpy(CHECK_NOTNULL(tmp_rhs_)->x, x, m_->num_rows() * sizeof(*x));
-  cholmod_dense* solution = CHECK_NOTNULL(ss->Solve(factor_, tmp_rhs_));
+  // TODO(sameeragarwal): Better error handling.
+  string status;
+  cholmod_dense* solution = CHECK_NOTNULL(ss->Solve(factor_, tmp_rhs_, &status));
   memcpy(y, solution->x, sizeof(*y) * num_rows);
   ss->Free(solution);
 }