Add check if file creation was successful

This commit is contained in:
2018-11-14 17:30:53 +01:00
parent 3cdf289671
commit e2cfe3154b
+11 -1
View File
@@ -223,6 +223,15 @@ void H5Writer::create_file(hsize_t frame_chunk)
#endif
file = H5::H5File(target_filename.c_str(), H5F_ACC_TRUNC);
if (file.getId() == -1) {
stringstream error_message;
using namespace date;
error_message << "[" << std::chrono::system_clock::now() << "]";
error_message << "Cannot create new file with filename " << target_filename << endl;
throw runtime_error(error_message.str());
}
// New file created - set this files chunk number.
current_frame_chunk = frame_chunk;
@@ -303,4 +312,5 @@ H5::H5File& DummyH5Writer::get_h5_file(){
error_message << "Cannot get the H5 file with the dummy writer." << endl;
throw runtime_error(error_message.str());
};
};