Commit c3be2777 authored by Patrik Huber's avatar Patrik Huber

MorphableModel load function now throws when given an invalid filename

parent 3ece236f
...@@ -227,12 +227,16 @@ private: ...@@ -227,12 +227,16 @@ private:
* *
* @param[in] filename Filename to a model. * @param[in] filename Filename to a model.
* @return The loaded Morphable Model. * @return The loaded Morphable Model.
* @throw std::runtime_error When the file given in \c filename fails to be opened (most likely because the file doesn't exist).
*/ */
MorphableModel load_model(std::string filename) MorphableModel load_model(std::string filename)
{ {
MorphableModel model; MorphableModel model;
std::ifstream file(filename, std::ios::binary); std::ifstream file(filename, std::ios::binary);
if (file.fail()) {
throw std::runtime_error("Error opening given file: " + filename);
}
cereal::BinaryInputArchive input_archive(file); cereal::BinaryInputArchive input_archive(file);
input_archive(model); input_archive(model);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment