diff --git a/GenericIO.cxx b/GenericIO.cxx index 08993408f80898413fcceb56bc1d67f01e4ebf81..b3cb88206051b690db34354d7252ac072e877b38 100644 --- a/GenericIO.cxx +++ b/GenericIO.cxx @@ -92,8 +92,8 @@ void GenericFileIO_MPI::open(const std::string &FN, bool ForReading, bool MustEx (!MustExist ? MPI_MODE_CREATE : 0)); if (MPI_File_open(Comm, const_cast<char *>(FileName.c_str()), amode, MPI_INFO_NULL, &FH) != MPI_SUCCESS) - throw runtime_error((!ForReading ? "Unable to create the file: " : - "Unable to open the file: ") + + throw runtime_error(((!ForReading && !MustExist) ? "Unable to create the file: " : + "Unable to open the file: ") + FileName); } @@ -193,8 +193,8 @@ void GenericFileIO_POSIX::open(const std::string &FN, bool ForReading, bool Must int mode = S_IRUSR | S_IWUSR | S_IRGRP; errno = 0; if ((FH = ::open(FileName.c_str(), flags, mode)) == -1) - throw runtime_error((!ForReading ? "Unable to create the file: " : - "Unable to open the file: ") + + throw runtime_error(((!ForReading && !MustExist) ? "Unable to create the file: " : + "Unable to open the file: ") + FileName + ": " + strerror(errno)); }