diff --git a/src/Network/NeuralNetwork.cpp b/src/Network/NeuralNetwork.cpp index abd045796407d288e1b4e75d8c2f2cfd9e0e07a5..ed0f9ad5bb3931476dd75e550469d4579962217d 100644 --- a/src/Network/NeuralNetwork.cpp +++ b/src/Network/NeuralNetwork.cpp @@ -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() {