Better exceptions

This commit is contained in:
Sebastian Messmer 2015-10-30 18:10:48 +01:00
parent cc99cb0ea5
commit 6836a1bd40
2 changed files with 6 additions and 0 deletions

View File

@ -120,6 +120,9 @@ inline Data &Data::FillWithZeroes() {
inline void Data::StoreToFile(const boost::filesystem::path &filepath) const {
std::ofstream file(filepath.c_str(), std::ios::binary | std::ios::trunc);
if (!file.good()) {
throw std::runtime_error("Could not open file for writing");
}
StoreToStream(file);
}

View File

@ -11,6 +11,9 @@ TempFile::TempFile(const bf::path &path, bool create)
: _path(path) {
if (create) {
ofstream file(_path.c_str());
if (!file.good()) {
throw std::runtime_error("Could not create tempfile");
}
}
}