]> OCCT Git - occt-copy.git/commitdiff
0032125: Application Framework, OCAF - need to have adequate message if document... CR32125_1
authorvro <vladislav.romashko@opencascade.com>
Tue, 20 Jul 2021 02:02:43 +0000 (05:02 +0300)
committervro <vladislav.romashko@opencascade.com>
Tue, 20 Jul 2021 02:02:43 +0000 (05:02 +0300)
A list of storage statuses (PCDM_StoreStatus) is extended for PCDM_SS_UnrecognizedFormat. It is set if
- extension of a document file name is not defined (the extension doesn't correspond to any declared file formats) or
- a storage driver is not found for the document storage format.

Modifications:
- CDF_StoreList.cxx: a unique exception is raised in case of the driver is not found by the document format.
- PCDM_StoreStatus.hxx: a new enumeration value is added - PCDM_SS_UnrecognizedFormat.
- DDocStd_ApplicationCommands.cxx: processing of a new enumeration value PCDM_SS_UnrecognizedFormat by SaveAs draw-command.
- XDEDRAW.cxx: processing of a new enumeration value PCDM_SS_UnrecognizedFormat by saveDoc draw-command.

src/CDF/CDF_StoreList.cxx
src/DDocStd/DDocStd_ApplicationCommands.cxx
src/PCDM/PCDM_StoreStatus.hxx
src/XDEDRAW/XDEDRAW.cxx

index 5ef2668fb63dd9cafb4c63e84c81952d249a1b00..6fa570fa67b2348b34dc5a49a72463077fc5929c 100644 (file)
@@ -27,6 +27,7 @@
 #include <PCDM_StorageDriver.hxx>
 #include <Standard_ErrorHandler.hxx>
 #include <Standard_NoSuchObject.hxx>
+#include <Standard_ProgramError.hxx>
 #include <TCollection_ExtendedString.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(CDF_StoreList,Standard_Transient)
@@ -99,7 +100,7 @@ PCDM_StoreStatus CDF_StoreList::Store (Handle(CDM_MetaData)& aMetaData,
           {
             Standard_SStream aMsg;
             aMsg <<"No storage driver does exist for this format: " << theDocument->StorageFormat() << (char)0;
-            throw Standard_Failure(aMsg.str().c_str());
+            throw Standard_ProgramError(aMsg.str().c_str());
           }
 
           // Reset the store-status.
@@ -130,6 +131,14 @@ PCDM_StoreStatus CDF_StoreList::Store (Handle(CDM_MetaData)& aMetaData,
       CAUGHT(anException, aStatusAssociatedText, TCollection_ExtendedString("metadatadriver failed; reason:"));
       status = PCDM_SS_DriverFailure;
     }
+    catch (Standard_ProgramError const& anException) {
+      CAUGHT(anException, aStatusAssociatedText, TCollection_ExtendedString("driver not found; reason:"));
+      status = PCDM_SS_UnrecognizedFormat;
+    }
+    catch (Standard_NoSuchObject const& anException) {
+      CAUGHT(anException, aStatusAssociatedText, TCollection_ExtendedString("driver not found; reason:"));
+      status = PCDM_SS_UnrecognizedFormat;
+    }
     catch (Standard_Failure const& anException) {
       CAUGHT(anException, aStatusAssociatedText, TCollection_ExtendedString("driver failed; reason:"));
       status = PCDM_SS_Failure; 
index c923df9cf540b718b705fe6ddbb24c433b86ad31..37aa27b8b475e879b0e9874bb1b8472a7f7f6f90 100644 (file)
@@ -336,6 +336,10 @@ static Standard_Integer DDocStd_SaveAs (Draw_Interpretor& di,
         di << "Error saving document: User break \n" ;
         break;
       }
+      case PCDM_SS_UnrecognizedFormat: {
+        di << "Error saving document: unrecognized document storage format " << D->StorageFormat() << "\n" ;
+        break;
+      }
       default:
         break;
       }
index cd0e56354c0a43ee91fc092318b02745621bbce7..4d089129b139cb435a51cbd6e886ab700bd6df92 100644 (file)
@@ -27,7 +27,8 @@ PCDM_SS_Failure,
 PCDM_SS_Doc_IsNull,
 PCDM_SS_No_Obj,
 PCDM_SS_Info_Section_Error,
-PCDM_SS_UserBreak
+PCDM_SS_UserBreak,
+PCDM_SS_UnrecognizedFormat
 };
 
 #endif // _PCDM_StoreStatus_HeaderFile
index bb9ecf0a79b419851ea9913ab83fbae205193bd4..184db58f78336460a95e3d21582c32215392d455 100644 (file)
@@ -192,6 +192,9 @@ static Standard_Integer saveDoc (Draw_Interpretor& di, Standard_Integer argc, co
     case PCDM_SS_UserBreak:
       di << "Storage error: user break\n";
       break;
+    case PCDM_SS_UnrecognizedFormat:
+      di << "Storage error: unrecognized document storage format " << D->StorageFormat() << "\n";
+      break;
   }
 
   return 0;