From b6e72ed6963f5adab3e57992bb574bbcccf40635 Mon Sep 17 00:00:00 2001 From: Matthew Marine Date: Fri, 19 Apr 2024 15:52:59 -0400 Subject: [PATCH] Fixed crash on WriteDREAM3D xdmf file (#921) * Avoids crashing when writing the xdmf file fails * Reports an error message through the WriteDREAM3DFilter fixes #915 --- .../src/SimplnxCore/Filters/WriteDREAM3DFilter.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteDREAM3DFilter.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteDREAM3DFilter.cpp index 647065c230..2786e93d0a 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteDREAM3DFilter.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/WriteDREAM3DFilter.cpp @@ -117,7 +117,13 @@ Result<> WriteDREAM3DFilter::executeImpl(DataStructure& dataStructure, const Arg if(writeXdmf) { fs::path xdmfFilePath = exportFilePath.replace_extension(".xdmf"); - fs::rename(xdmfFilePath, args.value(k_ExportFilePath).replace_extension(".xdmf")); + std::error_code errorCode; + fs::rename(xdmfFilePath, args.value(k_ExportFilePath).replace_extension(".xdmf"), errorCode); + if(errorCode) + { + std::string ss = fmt::format("Failed to rename xdmf file with error: '{}'", errorCode.message()); + return MakeErrorResult(errorCode.value(), ss); + } } } return results;