From fb62a1fc8e4f06b20ec8db79f61fdd812650b1a4 Mon Sep 17 00:00:00 2001 From: Hal Finkel <hfinkel@anl.gov> Date: Tue, 9 Jun 2020 09:25:12 -0500 Subject: [PATCH] The error should not say create if we did not try to create --- GenericIO.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GenericIO.cxx b/GenericIO.cxx index 0899340..b3cb882 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)); } -- GitLab