[mlpack-git] master: Add error handling when streams fail to open. (2720ddc)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Fri Dec 4 09:31:23 EST 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/458bd20685bdfd8a7918e1b64c45161f965e0080...1efafa13b304c7821d858754b0d2dab9a05795a7
>---------------------------------------------------------------
commit 2720ddc294241487a6ed01aa42dfff2be878702d
Author: Ryan Curtin <ryan at ratml.org>
Date: Fri Dec 4 06:29:03 2015 -0800
Add error handling when streams fail to open.
>---------------------------------------------------------------
2720ddc294241487a6ed01aa42dfff2be878702d
src/mlpack/methods/hmm/hmm_util_impl.hpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/mlpack/methods/hmm/hmm_util_impl.hpp b/src/mlpack/methods/hmm/hmm_util_impl.hpp
index 7b05363..4f34334 100644
--- a/src/mlpack/methods/hmm/hmm_util_impl.hpp
+++ b/src/mlpack/methods/hmm/hmm_util_impl.hpp
@@ -54,6 +54,9 @@ void LoadHMMAndPerformActionHelper(const std::string& modelFile,
ExtraInfoType* x)
{
std::ifstream ifs(modelFile);
+ if (ifs.fail())
+ Log::Fatal << "Cannot open model file '" << modelFile << "' for loading!"
+ << std::endl;
ArchiveType ar(ifs);
// Read in the unsigned integer that denotes the type of the model.
@@ -125,6 +128,9 @@ template<typename ArchiveType, typename HMMType>
void SaveHMMHelper(HMMType& hmm, const std::string& modelFile)
{
std::ofstream ofs(modelFile);
+ if (ofs.fail())
+ Log::Fatal << "Cannot open model file '" << modelFile << "' for saving!"
+ << std::endl;
ArchiveType ar(ofs);
// Write out the unsigned integer that denotes the type of the model.
More information about the mlpack-git
mailing list