[MOAB-dev] commit/MOAB: danwu: Partially applied error handling code to NC reader for testing. If we load a CAM-FV file and read variables that are on edges (not supported yet), error messages and stack traces will be printed out (examples/TestErrorHandling.cpp is updated to demonstrate this feature).

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Feb 21 17:59:28 CST 2014


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/617c8f597924/
Changeset:   617c8f597924
Branch:      error_handling_enhancement
User:        danwu
Date:        2014-02-22 00:59:00
Summary:     Partially applied error handling code to NC reader for testing. If we load a CAM-FV file and read variables that are on edges (not supported yet), error messages and stack traces will be printed out (examples/TestErrorHandling.cpp is updated to demonstrate this feature).

Affected #:  3 files

diff --git a/examples/TestErrorHandling.cpp b/examples/TestErrorHandling.cpp
index 0ea0fa4..3e16667 100644
--- a/examples/TestErrorHandling.cpp
+++ b/examples/TestErrorHandling.cpp
@@ -159,6 +159,19 @@ ErrorCode TestErrorHandling_5()
 
   return MB_SUCCESS;
 }
+
+// In this test case, a real error MB_NOT_IMPLEMENTED is returned by MOAB
+ErrorCode TestErrorHandling_6()
+{
+  Core moab;
+  Interface& mb = moab;
+
+  // Load a CAM-FV file and read a variable on edges (not supported yet)
+  string test_file = string(MESH_DIR) + string("/io/fv26x46x72.t.3.nc");
+  ErrorCode rval = mb.load_file(test_file.c_str(), NULL, "VARIABLE=US");CHK_ERR(rval);
+
+  return MB_SUCCESS;
+}
 #endif
 
 int main(int argc, char** argv)
@@ -190,6 +203,10 @@ int main(int argc, char** argv)
   cout << "--------------------Running test case 5 start--------------------" << endl;
   TestErrorHandling_5();
   cout << "--------------------Running test case 5 end----------------------\n" << endl;
+
+  cout << "--------------------Running test case 6 start--------------------" << endl;
+  TestErrorHandling_6();
+  cout << "--------------------Running test case 6 end----------------------\n" << endl;
 #endif
 
   MBErrorHandler_Finalize();

diff --git a/src/io/NCHelper.cpp b/src/io/NCHelper.cpp
index 9ef1332..2bed0c9 100644
--- a/src/io/NCHelper.cpp
+++ b/src/io/NCHelper.cpp
@@ -1027,7 +1027,8 @@ ErrorCode ScdNCHelper::read_variables(std::vector<std::string>& var_names, std::
 
   if (!vdatas.empty()) {
     rval = read_scd_variable_to_nonset(vdatas, tstep_nums);
-    ERRORR(rval, "Trouble read variables to entities verts/edges/faces.");
+    if (MB_SUCCESS != rval)
+      SET_ERR(rval, "Trouble reading variables to entities verts/edges/faces");
   }
 
   return MB_SUCCESS;
@@ -1103,11 +1104,8 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset_allocate(std::vector<ReadNC::
         range = &verts;
         break;
       case ReadNC::ENTLOCNSEDGE:
-        ERRORR(MB_FAILURE, "Reading edge data not implemented yet.");
-        break;
       case ReadNC::ENTLOCEWEDGE:
-        ERRORR(MB_FAILURE, "Reading edge data not implemented yet.");
-        break;
+        SET_ERR(MB_NOT_IMPLEMENTED, "Reading edge data not implemented yet");
       case ReadNC::ENTLOCFACE:
         // Faces
         vdatas[i].readStarts[2] = lCDims[1];
@@ -1164,7 +1162,8 @@ ErrorCode ScdNCHelper::read_scd_variable_to_nonset(std::vector<ReadNC::VarData>&
   DebugOutput& dbgOut = _readNC->dbgOut;
 
   ErrorCode rval = read_scd_variable_to_nonset_allocate(vdatas, tstep_nums);
-  ERRORR(rval, "Trouble allocating read variables.");
+  if (MB_SUCCESS != rval)
+    SET_ERR(rval, "Trouble allocating space to read variables");
 
   // Finally, read into that space
   int success;

diff --git a/src/io/ReadNC.cpp b/src/io/ReadNC.cpp
index a0e02b4..38cafd2 100644
--- a/src/io/ReadNC.cpp
+++ b/src/io/ReadNC.cpp
@@ -127,9 +127,7 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
 
   // Read variables onto grid
   if (!noVars) {
-    rval = myHelper->read_variables(var_names, tstep_nums);
-    if (MB_FAILURE == rval)
-      return rval;
+    rval = myHelper->read_variables(var_names, tstep_nums);CHK_ERR(rval);
   }
   else {
     // Read dimension variables by default (the dimensions that are also variables)

Repository URL: https://bitbucket.org/fathomteam/moab/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the moab-dev mailing list