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

ENH: Added check when DataSet constructor gets path to the file, which is not...

ENH: Added check when DataSet constructor gets path to the file, which is not a correct DataSet archive.
parent 48a19669
No related branches found
No related tags found
No related merge requests found
......@@ -22,8 +22,13 @@ namespace lib4neuro {
DataSet::DataSet(std::string file_path) {
std::ifstream ifs(file_path);
if(ifs.is_open()) {
boost::archive::text_iarchive ia(ifs);
ia >> *this;
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 " + file_path + " couldn't be open!");
......
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