Skip to content
Snippets Groups Projects
Commit a2696b27 authored by Martin Beseda's avatar Martin Beseda
Browse files

ENH: Added check of filepath existence.

parent 3953f05e
No related branches found
No related tags found
No related merge requests found
......@@ -39,9 +39,19 @@ namespace lib4neuro {
NeuralNetwork::NeuralNetwork(std::string filepath) {
::std::ifstream ifs(filepath);
boost::archive::text_iarchive ia(ifs);
ia >> *this;
ifs.close();
if(ifs.is_open()) {
try {
boost::archive::text_iarchive ia(ifs);
ia >> *this;
}catch(boost::archive::archive_exception& e) {
THROW_RUNTIME_ERROR("Serialized archive error: '" + e.what() + "'! Please, check if your file is really "
"the serialized DataSet.");
}
ifs.close();
} else {
THROW_RUNTIME_ERROR("File '" + filepath + "' couldn't be open!");
}
}
NeuralNetwork::~NeuralNetwork() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment