Salome HOME
Adding error handling.
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_XAOImport.cpp
index 1440c8142503e8284ae24a4bf4cb336fd257be1a..7647f71227d11368c6f34ad96ab366005e3c30e2 100644 (file)
@@ -6,8 +6,6 @@
 
 #include <GeomAlgoAPI_XAOImport.h>
 
-#include <cassert>
-
 #include <TopoDS_Shape.hxx>
 
 #include <XAO_XaoExporter.hxx>
  */
 //=============================================================================
 std::shared_ptr<GeomAPI_Shape> XAOImport(const std::string& theFileName,
-                                         const std::string&,
                                          std::string& theError,
                                          XAO::Xao* theXao)
 {
-  assert(theXao);
-
   #ifdef _DEBUG
   std::cout << "Import XAO from file " << theFileName << std::endl;
   #endif
+  if (theFileName.empty() || !theXao) {
+    theError = "An invalid argument.";
+    return std::shared_ptr<GeomAPI_Shape>();
+  }
+
   TopoDS_Shape aShape;
   try {
-//    XAO::Xao aXao;
-    if (XAO::XaoExporter::readFromFile(theFileName, theXao/*&aXao*/)) {
-      XAO::Geometry* aGeometry = /*aXao*/theXao->getGeometry();
+    if (XAO::XaoExporter::readFromFile(theFileName, theXao)) {
+      XAO::Geometry* aGeometry = theXao->getGeometry();
       XAO::Format aFormat = aGeometry->getFormat();
       if (aFormat == XAO::BREP) {
         if (XAO::BrepGeometry* aBrepGeometry = dynamic_cast<XAO::BrepGeometry*>(aGeometry))