diff --git a/gtsam/geometry/Cal3_S2.cpp b/gtsam/geometry/Cal3_S2.cpp index 54deedfdc..980f7f969 100644 --- a/gtsam/geometry/Cal3_S2.cpp +++ b/gtsam/geometry/Cal3_S2.cpp @@ -44,8 +44,7 @@ Cal3_S2::Cal3_S2(const std::string &path) : if (infile) infile >> fx_ >> fy_ >> s_ >> u0_ >> v0_; else { - printf("Unable to load the calibration\n"); - exit(0); + throw std::runtime_error("Cal3_S2: Unable to load the calibration"); } infile.close(); diff --git a/gtsam/linear/JacobianFactor.cpp b/gtsam/linear/JacobianFactor.cpp index 1f5e5557c..2373e7df0 100644 --- a/gtsam/linear/JacobianFactor.cpp +++ b/gtsam/linear/JacobianFactor.cpp @@ -164,9 +164,10 @@ boost::tuple, DenseIndex, DenseIndex> _countDims( n += vardim; } else { if(!(varDims[jointVarpos] == vardim)) { - cout << "Factor " << sourceFactorI << " variable " << DefaultKeyFormatter(sourceFactor.keys()[sourceVarpos]) << - " has different dimensionality of " << vardim << " instead of " << varDims[jointVarpos] << endl; - exit(1); + std::stringstream ss; + ss << "Factor " << sourceFactorI << " variable " << DefaultKeyFormatter(sourceFactor.keys()[sourceVarpos]) << + " has different dimensionality of " << vardim << " instead of " << varDims[jointVarpos]; + throw std::runtime_error(ss.str()); } } #else diff --git a/gtsam/slam/SmartProjectionFactor.h b/gtsam/slam/SmartProjectionFactor.h index e554e0c85..cbeed77c5 100644 --- a/gtsam/slam/SmartProjectionFactor.h +++ b/gtsam/slam/SmartProjectionFactor.h @@ -183,12 +183,9 @@ public: std::vector Gs(numKeys * (numKeys + 1) / 2); std::vector gs(numKeys); - if (this->measured_.size() != cameras.size()) { - std::cout - << "SmartProjectionHessianFactor: this->measured_.size() inconsistent with input" - << std::endl; - exit(1); - } + if (this->measured_.size() != cameras.size()) + throw std::runtime_error("SmartProjectionHessianFactor: this->measured_" + ".size() inconsistent with input"); triangulateSafe(cameras); diff --git a/gtsam_unstable/slam/SmartStereoProjectionFactor.h b/gtsam_unstable/slam/SmartStereoProjectionFactor.h index f32dd3b3e..42ffa9e2f 100644 --- a/gtsam_unstable/slam/SmartStereoProjectionFactor.h +++ b/gtsam_unstable/slam/SmartStereoProjectionFactor.h @@ -206,12 +206,9 @@ public: std::vector Gs(numKeys * (numKeys + 1) / 2); std::vector gs(numKeys); - if (this->measured_.size() != cameras.size()) { - std::cout - << "SmartStereoProjectionHessianFactor: this->measured_.size() inconsistent with input" - << std::endl; - exit(1); - } + if (this->measured_.size() != cameras.size()) + throw std::runtime_error("SmartStereoProjectionHessianFactor: this->" + "measured_.size() inconsistent with input"); triangulateSafe(cameras);