Salome HOME
Message d'erreur en l'absence de fichier
authorGérald NICOLAS <gerald.nicolas@edf.fr>
Tue, 9 Feb 2021 16:05:33 +0000 (17:05 +0100)
committerGérald NICOLAS <gerald.nicolas@edf.fr>
Tue, 9 Feb 2021 16:05:33 +0000 (17:05 +0100)
src/SMESH/MG_ADAPT.cxx
src/SMESH_I/MG_ADAPT_i.cxx

index 64030554123fd51a5d62048d71994a6d79ac317b..9a44b93d7be57f426fbdbd2e86a2d6a85cb90643 100644 (file)
@@ -30,6 +30,9 @@
 #include "MEDFileField.hxx"
 #include "MEDCouplingFieldDouble.hxx"
 
+#include <SALOME_NamingService.hxx>
+#include <Utils_SALOME_Exception.hxx>
+
 #include <utilities.h>
 #include <iostream>
 #include <unistd.h>
@@ -219,9 +222,25 @@ MgAdaptHypothesisData* MgAdapt::getData() const
 }
 void MgAdapt::setMedFileIn(std::string fileName)
 {
-  medFileIn  = fileName;
-  if (medFileOut == "") // default MED file Out
-    medFileOut = remove_extension( fileName )+ ".adapt.med";
+  if ( isFileExist(fileName) )
+  {
+    medFileIn = fileName;
+
+    if (medFileOut == "") // default MED file Out
+      medFileOut = remove_extension( fileName )+ ".adapt.med";
+  }
+  else
+  {
+    std::cout << "\nThe file " + fileName + " does not exist.\n" << std::endl;
+//     SALOME::ExceptionStruct es;
+//     es.type = SALOME::BAD_PARAM;
+//     std::string text = "\nThe file " + fileName + " does not exist.\n" ;
+//     std::cout << text << std::endl;
+//     es.text = "The mesh file does not exist.";
+//     es.text = CORBA::string_dup(text.c_str());
+//     throw SALOME::SALOME_Exception(es);
+    throw SALOME_Exception(("The file " + fileName + " does not exist." ).c_str() );
+  }
 }
 
 std::string MgAdapt::getMedFileIn()
@@ -233,7 +252,6 @@ void MgAdapt::setMedFileOut(std::string fileOut)
 {
   medFileOut = fileOut;
 }
-
 std::string MgAdapt::getMedFileOut()
 {
   return medFileOut;
@@ -363,7 +381,15 @@ bool MgAdapt::getRemoveOnSuccess()
 }
 void MgAdapt::setSizeMapFile(std::string mapFile)
 {
-  sizeMapFile = mapFile;
+  if ( mapFile == "" || isFileExist(mapFile) )
+  {
+    sizeMapFile = mapFile;
+  }
+  else
+  {
+    std::cout << "\nThe file " + mapFile + " does not exist.\n" << std::endl;
+    throw SALOME_Exception(("The file " + mapFile + " does not exist." ).c_str() );
+  }
 }
 std::string MgAdapt::getSizeMapFile()
 {
@@ -428,7 +454,6 @@ bool MgAdapt::getPrintLogInFile()
   return printLogInFile;
 }
 
-
 bool MgAdapt::setAll()
 {
 
@@ -1315,8 +1340,13 @@ med_idt MgAdapt::openMedFile(const std::string aFile)
   med_idt medIdt = MEDfileOpen(aFile.c_str(),MED_ACC_RDONLY);
   if (medIdt <0)
   {
-    //~addMessage( ToComment(" error: Can't open  ") << aFile, /*fatal=*/true );
-    ;
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::BAD_PARAM;
+    std::string text = "The med file " + aFile + " cannot be opened." ;
+//     es.text = "The mesh file does not exist.";
+    es.text = CORBA::string_dup(text.c_str());
+    throw SALOME::SALOME_Exception(es);
+    return 0;
   }
   return medIdt;
 }
index ec2c9d30d53489664f7ce1a2d83246c777feaa8e..fbe27fd473246ce4eb130d3273bf7855a30d9be6 100644 (file)
 //
 
 #include "MG_ADAPT_i.hxx"
-//~#include "ADAPT_Gen_i.hxx"
+
 #include "string.h"
 #include "SMESH_Gen_i.hxx"
 #include <SMESH_Gen.hxx>
 #include <SALOMEconfig.h>
 #include CORBA_CLIENT_HEADER(SALOMEDS)
-//~#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
-//~#include CORBA_CLIENT_HEADER(SMESH_Gen)
 
 
 //=============================================================================