From: vro Date: Mon, 19 Jul 2021 16:22:36 +0000 (+0300) Subject: 0032125: Application Framework, OCAF - need to have adequate message if document... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=c723a13eee36471898b6e22478cead511e9a3ecf;p=occt-copy.git 0032125: Application Framework, OCAF - need to have adequate message if document cannot be saved due to unrecognized format 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 by the draw-command. --- diff --git a/src/CDF/CDF_StoreList.cxx b/src/CDF/CDF_StoreList.cxx index 5ef2668fb6..6fa570fa67 100644 --- a/src/CDF/CDF_StoreList.cxx +++ b/src/CDF/CDF_StoreList.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include 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; diff --git a/src/DDocStd/DDocStd_ApplicationCommands.cxx b/src/DDocStd/DDocStd_ApplicationCommands.cxx index c923df9cf5..37aa27b8b4 100644 --- a/src/DDocStd/DDocStd_ApplicationCommands.cxx +++ b/src/DDocStd/DDocStd_ApplicationCommands.cxx @@ -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; } diff --git a/src/PCDM/PCDM_StoreStatus.hxx b/src/PCDM/PCDM_StoreStatus.hxx index cd0e56354c..4d089129b1 100644 --- a/src/PCDM/PCDM_StoreStatus.hxx +++ b/src/PCDM/PCDM_StoreStatus.hxx @@ -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