From 2e6094e4e128db04b912ea085328e8704ad867be Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Fri, 22 Jan 2016 11:41:58 +0100 Subject: [PATCH] [A/U/ME] AddTopLayer: unique_ptr + more specific error output. --- Applications/Utils/MeshEdit/AddTopLayer.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Applications/Utils/MeshEdit/AddTopLayer.cpp b/Applications/Utils/MeshEdit/AddTopLayer.cpp index f0d7cb482d6..abc47c3d8bc 100644 --- a/Applications/Utils/MeshEdit/AddTopLayer.cpp +++ b/Applications/Utils/MeshEdit/AddTopLayer.cpp @@ -53,17 +53,25 @@ int main (int argc, char* argv[]) cmd.parse(argc, argv); INFO("Reading mesh \"%s\" ... ", mesh_arg.getValue().c_str()); - MeshLib::Mesh * subsfc_mesh(FileIO::readMeshFromFile(mesh_arg.getValue())); + auto subsfc_mesh = std::unique_ptr<MeshLib::Mesh>( + FileIO::readMeshFromFile(mesh_arg.getValue())); + if (!subsfc_mesh) { + ERR("Error reading mesh \"%s\".", mesh_arg.getValue().c_str()); + return EXIT_FAILURE; + } INFO("done."); - std::unique_ptr<MeshLib::Mesh> result (MeshLib::addTopLayerToMesh( - *subsfc_mesh, layer_thickness_arg.getValue(), mesh_out_arg.getValue() - )); + std::unique_ptr<MeshLib::Mesh> result(MeshLib::addTopLayerToMesh( + *subsfc_mesh, layer_thickness_arg.getValue(), mesh_out_arg.getValue())); + if (!result) { + ERR("Failure while adding top layer.") + return EXIT_FAILURE; + } INFO("Writing mesh \"%s\" ... ", mesh_out_arg.getValue().c_str()); FileIO::VtuInterface mesh_io(result.get(), vtkXMLWriter::Binary); mesh_io.writeToFile(mesh_out_arg.getValue()); INFO("done."); - return 0; + return EXIT_SUCCESS; } -- GitLab