0028367: Draw Harness - XSave should print an error on store failure
authorkgv <kgv@opencascade.com>
Wed, 18 Jan 2017 07:59:35 +0000 (10:59 +0300)
committerapn <apn@opencascade.com>
Thu, 26 Jan 2017 10:22:29 +0000 (13:22 +0300)
src/XDEDRAW/XDEDRAW.cxx

index b26a27c..273f62e 100644 (file)
@@ -142,16 +142,46 @@ static Standard_Integer saveDoc (Draw_Interpretor& di, Standard_Integer argc, co
     if (!DDocStd::GetDocument(argv[1],D)) return 1;
   }
 
-  if (argc == 3 ) {
+  PCDM_StoreStatus aStatus = PCDM_SS_Doc_IsNull;
+  if (argc == 3)
+  {
     TCollection_ExtendedString path (argv[2]);
-    A->SaveAs(D,path);
-    return 0;
+    aStatus = A->SaveAs (D, path);
   }
-  if (!D->IsSaved()) {
-    di << "this document has never been saved\n";
+  else if (!D->IsSaved())
+  {
+    std::cout << "Storage error: this document has never been saved\n";
     return 1;
   }
-  A->Save(D);
+  else
+  {
+    aStatus = A->Save(D);
+  }
+
+  switch (aStatus)
+  {
+    case PCDM_SS_OK:
+      break;
+    case PCDM_SS_DriverFailure:
+      di << "Storage error: driver failure\n";
+      break;
+    case PCDM_SS_WriteFailure:
+      di << "Storage error: write failure\n";
+      break;
+    case PCDM_SS_Failure:
+      di << "Storage error: general failure\n";
+      break;
+    case PCDM_SS_Doc_IsNull:
+      di << "Storage error: document is NULL\n";
+      break;
+    case PCDM_SS_No_Obj:
+      di << "Storage error: no object\n";
+      break;
+    case PCDM_SS_Info_Section_Error:
+      di << "Storage error: section error\n";
+      break;
+  }
+
   return 0;
 }