Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
3cdea64
Refactor error handling: Replace Storage exceptions with error state …
claude Nov 5, 2025
39cb9d1
Fix compilation errors: remove SetErrorStatus from static functions a…
claude Nov 5, 2025
6bf6770
Fix dangling catch blocks: restore try keywords for Standard_Failure …
claude Nov 5, 2025
3d8219f
Address Rabbit AI code review feedback: fix critical error handling i…
claude Nov 5, 2025
d7f5fb6
Fix compilation errors and address CodeRabbit AI critical issues
claude Nov 5, 2025
7017ee1
Remove last remaining catch blocks for deprecated Storage_Stream exce…
claude Nov 5, 2025
4778bb1
// formatting
dpasukhi Nov 5, 2025
c1662dc
Fix error checks placement in Storage_HeaderData.cxx
claude Nov 5, 2025
b48a589
Add thread-safety documentation to Storage_BaseDriver error state man…
claude Nov 5, 2025
d653b31
Fix two critical CodeRabbit issues: error context and stream validation
claude Nov 5, 2025
84c8c7b
Remove unnecessary OCC_CATCH_SIGNALS macros from error handling refac…
claude Nov 5, 2025
afdca4a
Fix two critical CodeRabbit issues: error context and stream validation
claude Nov 5, 2025
852941e
Add missing error checks after driver method calls
claude Nov 6, 2025
930bf2f
Remove vestigial braces and unused includes from error handling refac…
claude Nov 6, 2025
4ecdec0
Remove unused exception-related includes after error handling refacto…
claude Nov 6, 2025
ff7e294
Use Standard_DEPRECATED macro for exception classes
claude Nov 6, 2025
6a3558a
Apply formatting fixes for macro definitions and deprecation attributes
claude Nov 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 8 additions & 27 deletions src/ApplicationFramework/TKStd/StdStorage/StdStorage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,11 @@ Storage_Error StdStorage::Read(const Handle(Storage_BaseDriver)& theDriver,
for (Standard_Integer i = 1; i <= aNbRefs; i++)
{
Standard_Integer aRef = 0, aType = 0;
try
{
OCC_CATCH_SIGNALS
theDriver->ReadReferenceType(aRef, aType);
anError = Storage_VSOk;
}
catch (Storage_StreamTypeMismatchError const&)
{
anError = Storage_VSTypeMismatch;
}

anError = theDriver->ErrorStatus();
if (anError != Storage_VSOk)
return anError;

Expand All @@ -152,25 +146,11 @@ Storage_Error StdStorage::Read(const Handle(Storage_BaseDriver)& theDriver,

for (Standard_Integer i = 1; i <= aHeaderData->NumberOfObjects(); i++)
{
try
{
OCC_CATCH_SIGNALS
aReadData.ReadPersistentObject(i);
anError = Storage_VSOk;
}
catch (Storage_StreamTypeMismatchError const&)
{
anError = Storage_VSTypeMismatch;
}
catch (Storage_StreamFormatError const&)
{
anError = Storage_VSFormatError;
}
catch (Storage_StreamReadError const&)
{
anError = Storage_VSFormatError;
}

anError = theDriver->ErrorStatus();
if (anError != Storage_VSOk)
return anError;
}
Expand Down Expand Up @@ -269,7 +249,6 @@ Storage_Error StdStorage::Write(const Handle(Storage_BaseDriver)& theDriver,
aHeaderData->SetStorageVersion(StdStorage::Version());
aHeaderData->SetNumberOfObjects(aPObjs.Length());

try
{
// Write header section
if (!aHeaderData->Write(theDriver))
Expand All @@ -295,7 +274,13 @@ Storage_Error StdStorage::Write(const Handle(Storage_BaseDriver)& theDriver,
{
Handle(StdObjMgt_Persistent) aPObj = anIt.Value();
if (!aPObj.IsNull())
{
theDriver->WriteReferenceType(aPObj->RefNum(), aPObj->TypeNum());

anError = theDriver->ErrorStatus();
if (anError != Storage_VSOk)
return anError;
}
}

anError = theDriver->EndWriteRefSection();
Expand All @@ -319,10 +304,6 @@ Storage_Error StdStorage::Write(const Handle(Storage_BaseDriver)& theDriver,
if (anError != Storage_VSOk)
return anError;
}
catch (Storage_StreamWriteError const&)
{
return Storage_VSWriteError;
}

return Storage_VSOk;
}
52 changes: 12 additions & 40 deletions src/ApplicationFramework/TKStd/StdStorage/StdStorage_HeaderData.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ Standard_Boolean StdStorage_HeaderData::Read(const Handle(Storage_BaseDriver)& t
return Standard_False;
}

try
{
OCC_CATCH_SIGNALS
theDriver->ReadInfo(myNBObj,
myStorageVersion,
myDate,
Expand All @@ -58,15 +56,10 @@ Standard_Boolean StdStorage_HeaderData::Read(const Handle(Storage_BaseDriver)& t
myDataType,
myUserInfo);
}
catch (Storage_StreamTypeMismatchError const&)
{
myErrorStatus = Storage_VSTypeMismatch;
myErrorStatusExt = "ReadInfo";
return Standard_False;
}
catch (Storage_StreamExtCharParityError const&)

if (theDriver->ErrorStatus() != Storage_VSOk)
{
myErrorStatus = Storage_VSExtCharParityError;
myErrorStatus = theDriver->ErrorStatus();
myErrorStatusExt = "ReadInfo";
return Standard_False;
}
Expand All @@ -86,20 +79,13 @@ Standard_Boolean StdStorage_HeaderData::Read(const Handle(Storage_BaseDriver)& t
return Standard_False;
}

try
{
OCC_CATCH_SIGNALS
theDriver->ReadComment(myComments);
}
catch (Storage_StreamTypeMismatchError const&)
{
myErrorStatus = Storage_VSTypeMismatch;
myErrorStatusExt = "ReadComment";
return Standard_False;
}
catch (Storage_StreamExtCharParityError const&)

if (theDriver->ErrorStatus() != Storage_VSOk)
{
myErrorStatus = Storage_VSExtCharParityError;
myErrorStatus = theDriver->ErrorStatus();
myErrorStatusExt = "ReadComment";
return Standard_False;
}
Expand Down Expand Up @@ -132,9 +118,7 @@ Standard_Boolean StdStorage_HeaderData::Write(const Handle(Storage_BaseDriver)&
return Standard_False;
}

try
{
OCC_CATCH_SIGNALS
theDriver->WriteInfo(myNBObj,
myStorageVersion,
myDate,
Expand All @@ -145,15 +129,10 @@ Standard_Boolean StdStorage_HeaderData::Write(const Handle(Storage_BaseDriver)&
myDataType,
myUserInfo);
}
catch (Storage_StreamTypeMismatchError const&)
{
myErrorStatus = Storage_VSTypeMismatch;
myErrorStatusExt = "WriteInfo";
return Standard_False;
}
catch (Storage_StreamExtCharParityError const&)

if (theDriver->ErrorStatus() != Storage_VSOk)
{
myErrorStatus = Storage_VSExtCharParityError;
myErrorStatus = theDriver->ErrorStatus();
myErrorStatusExt = "WriteInfo";
return Standard_False;
}
Expand All @@ -173,20 +152,13 @@ Standard_Boolean StdStorage_HeaderData::Write(const Handle(Storage_BaseDriver)&
return Standard_False;
}

try
{
OCC_CATCH_SIGNALS
theDriver->WriteComment(myComments);
}
catch (Storage_StreamTypeMismatchError const&)
{
myErrorStatus = Storage_VSTypeMismatch;
myErrorStatusExt = "WriteComment";
return Standard_False;
}
catch (Storage_StreamExtCharParityError const&)

if (theDriver->ErrorStatus() != Storage_VSOk)
{
myErrorStatus = Storage_VSExtCharParityError;
myErrorStatus = theDriver->ErrorStatus();
myErrorStatusExt = "WriteComment";
return Standard_False;
}
Expand Down
17 changes: 7 additions & 10 deletions src/ApplicationFramework/TKStd/StdStorage/StdStorage_RootData.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <StdStorage_RootData.hxx>
#include <StdStorage_Root.hxx>
#include <Storage_BaseDriver.hxx>
#include <Storage_StreamTypeMismatchError.hxx>
#include <TCollection_AsciiString.hxx>

IMPLEMENT_STANDARD_RTTIEXT(StdStorage_RootData, Standard_Transient)
Expand Down Expand Up @@ -50,14 +49,13 @@ Standard_Boolean StdStorage_RootData::Read(const Handle(Storage_BaseDriver)& the
Standard_Integer len = theDriver->RootSectionSize();
for (Standard_Integer i = 1; i <= len; i++)
{
try
{
OCC_CATCH_SIGNALS
theDriver->ReadRoot(aRootName, aRef, aTypeName);
}
catch (Storage_StreamTypeMismatchError const&)

if (theDriver->ErrorStatus() != Storage_VSOk)
{
myErrorStatus = Storage_VSTypeMismatch;
myErrorStatus = theDriver->ErrorStatus();
myErrorStatusExt = "ReadRoot";
return Standard_False;
}
Expand Down Expand Up @@ -98,15 +96,14 @@ Standard_Boolean StdStorage_RootData::Write(const Handle(Storage_BaseDriver)& th
for (StdStorage_MapOfRoots::Iterator anIt(myObjects); anIt.More(); anIt.Next())
{
const Handle(StdStorage_Root)& aRoot = anIt.Value();
try
{
OCC_CATCH_SIGNALS
theDriver->WriteRoot(aRoot->Name(), aRoot->Reference(), aRoot->Type());
}
catch (Storage_StreamTypeMismatchError const&)

if (theDriver->ErrorStatus() != Storage_VSOk)
{
myErrorStatus = Storage_VSTypeMismatch;
myErrorStatusExt = "ReadRoot";
myErrorStatus = theDriver->ErrorStatus();
myErrorStatusExt = "WriteRoot";
return Standard_False;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,13 @@ Standard_Boolean StdStorage_TypeData::Read(const Handle(Storage_BaseDriver)& the
Standard_Integer len = theDriver->TypeSectionSize();
for (Standard_Integer i = 1; i <= len; i++)
{
try
{
OCC_CATCH_SIGNALS
theDriver->ReadTypeInformations(aTypeNum, aTypeName);
}
catch (Storage_StreamTypeMismatchError const&)

if (theDriver->ErrorStatus() != Storage_VSOk)
{
myErrorStatus = Storage_VSTypeMismatch;
myErrorStatus = theDriver->ErrorStatus();
myErrorStatusExt = "ReadTypeInformations";
return Standard_False;
}
Expand Down Expand Up @@ -98,14 +97,13 @@ Standard_Boolean StdStorage_TypeData::Write(const Handle(Storage_BaseDriver)& th
theDriver->SetTypeSectionSize(len);
for (Standard_Integer i = 1; i <= len; i++)
{
try
{
OCC_CATCH_SIGNALS
theDriver->WriteTypeInformations(i, Type(i));
}
catch (Storage_StreamTypeMismatchError const&)

if (theDriver->ErrorStatus() != Storage_VSOk)
{
myErrorStatus = Storage_VSTypeMismatch;
myErrorStatus = theDriver->ErrorStatus();
myErrorStatusExt = "WriteTypeInformations";
return Standard_False;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
#include <Storage_TypeData.hxx>
#include <Storage_RootData.hxx>
#include <Storage_BaseDriver.hxx>
#include <Storage_StreamTypeMismatchError.hxx>
#include <Storage_StreamFormatError.hxx>
#include <Storage_StreamReadError.hxx>

#include <PCDM.hxx>
#include <PCDM_ReadWriter.hxx>
Expand Down Expand Up @@ -179,19 +176,11 @@ Handle(StdObjMgt_Persistent) StdLDrivers_DocumentRetrievalDriver::read(
for (i = 1; i <= len; i++)
{
Standard_Integer aRef = 0, aType = 0;
Storage_Error anError;
try
{
OCC_CATCH_SIGNALS
aFileDriver->ReadReferenceType(aRef, aType);
anError = Storage_VSOk;
}
catch (Storage_StreamTypeMismatchError const&)
{
anError = Storage_VSTypeMismatch;
}

raiseOnStorageError(anError);
raiseOnStorageError(aFileDriver->ErrorStatus());

aReadData.CreatePersistentObject(aRef, anInstantiators(aType));
}
Expand All @@ -203,27 +192,11 @@ Handle(StdObjMgt_Persistent) StdLDrivers_DocumentRetrievalDriver::read(

for (i = 1; i <= theHeaderData.NumberOfObjects(); i++)
{
Storage_Error anError;
try
{
OCC_CATCH_SIGNALS
aReadData.ReadPersistentObject(i);
anError = Storage_VSOk;
}
catch (Storage_StreamTypeMismatchError const&)
{
anError = Storage_VSTypeMismatch;
}
catch (Storage_StreamFormatError const&)
{
anError = Storage_VSFormatError;
}
catch (Storage_StreamReadError const&)
{
anError = Storage_VSFormatError;
}

raiseOnStorageError(anError);
raiseOnStorageError(aFileDriver->ErrorStatus());
}

raiseOnStorageError(aFileDriver->EndReadDataSection());
Expand Down
Loading
Loading