Commit 1d1c39f8 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

XMLVTK mesh readers: throw a meaningful error when the input file does not exist

Before this change, the error was:

XMLVTK error: failed to parse the file as an XML document.
parent 0c166848
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@

#include <map>
#include <set>
#include <experimental/filesystem>

#include <TNL/Meshes/Readers/MeshReader.h>
#include <TNL/base64.h>
@@ -286,6 +287,12 @@ public:
#ifdef HAVE_TINYXML2
      using namespace tinyxml2;

      namespace fs = std::experimental::filesystem;
      if( ! fs::exists( fileName ) )
         throw MeshReaderError( "XMLVTK", "file '" + fileName + "' does not exist" );
      if( fs::is_directory( fileName ) )
         throw MeshReaderError( "XMLVTK", "path '" + fileName + "' is a directory" );

      // load and verify XML
      tinyxml2::XMLError status = dom.LoadFile( fileName.c_str() );
      if( status != XML_SUCCESS )