expand exception message to include cause of file open failure

This commit is contained in:
Axel Kohlmeyer
2021-04-15 11:57:48 -04:00
parent 6e739c04e4
commit 0870a56093
2 changed files with 4 additions and 2 deletions

View File

@ -62,7 +62,8 @@ PotentialFileReader::PotentialFileReader(LAMMPS *lmp,
try {
reader = open_potential(filename);
if (!reader) {
error->one(FLERR, fmt::format("cannot open {} potential file {}", potential_name, filename));
error->one(FLERR, fmt::format("cannot open {} potential file {}: {}",
potential_name, filename, utils::getsyserror()));
}
} catch (FileReaderException &e) {
error->one(FLERR, e.what());

View File

@ -46,7 +46,8 @@ TextFileReader::TextFileReader(const std::string &filename, const std::string &f
fp = fopen(filename.c_str(), "r");
if (fp == nullptr) {
throw FileReaderException(fmt::format("cannot open {} file {}", filetype, filename));
throw FileReaderException(fmt::format("cannot open {} file {}: {}",
filetype, filename, utils::getsyserror()));
}
}