Skip to content

Commit d1b00bf

Browse files
authored
Coding - Reducing relying on exceptions (Open-Cascade-SAS#676)
- Replaced try-catch blocks with explicit validation checks in PCDM_ReadWriter_1.cxx - Added division-by-zero protection in XSDRAWSTL.cxx using precision-based comparison - Improved error handling for integer parsing operations
1 parent a50e3c9 commit d1b00bf

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

src/ApplicationFramework/TKCDF/PCDM/PCDM_ReadWriter_1.cxx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,13 @@ Standard_Integer PCDM_ReadWriter_1::ReadReferenceCounter(
259259
{
260260
if (refUserInfo(i).Search(REFERENCE_COUNTER) != -1)
261261
{
262-
try
262+
TCollection_AsciiString aToken = refUserInfo(i).Token(" ", 2);
263+
if (aToken.IsIntegerValue())
263264
{
264-
OCC_CATCH_SIGNALS theReferencesCounter = refUserInfo(i).Token(" ", 2).IntegerValue();
265+
theReferencesCounter = aToken.IntegerValue();
265266
}
266-
catch (Standard_Failure const&)
267+
else
267268
{
268-
// std::cout << "warning: could not read the reference counter in " << aFileName <<
269-
// std::endl;
270269
TCollection_ExtendedString aMsg("Warning: ");
271270
aMsg = aMsg.Cat("could not read the reference counter in ").Cat(aFileName).Cat("\0");
272271
if (!theMsgDriver.IsNull())
@@ -426,13 +425,13 @@ Standard_Integer PCDM_ReadWriter_1::ReadDocumentVersion(
426425
{
427426
if (refUserInfo(i).Search(MODIFICATION_COUNTER) != -1)
428427
{
429-
try
428+
TCollection_AsciiString aToken = refUserInfo(i).Token(" ", 2);
429+
if (aToken.IsIntegerValue())
430430
{
431-
OCC_CATCH_SIGNALS theVersion = refUserInfo(i).Token(" ", 2).IntegerValue();
431+
theVersion = aToken.IntegerValue();
432432
}
433-
catch (Standard_Failure const&)
433+
else
434434
{
435-
// std::cout << "warning: could not read the version in " << aFileName << std::endl;
436435
TCollection_ExtendedString aMsg("Warning: ");
437436
aMsg = aMsg.Cat("could not read the version in ").Cat(aFileName).Cat("\0");
438437
if (!theMsgDriver.IsNull())

src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL.cxx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -820,14 +820,13 @@ static Standard_Integer meshcolors(Draw_Interpretor& theDI,
820820
aDataSource->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aType);
821821

822822
Standard_Real aScaleValue;
823-
try
823+
if (aDelta > Precision::Confusion())
824824
{
825-
OCC_CATCH_SIGNALS
826-
aScaleValue = (aCoords.Value(1) - (Standard_Real)aMinX) / aDelta;
825+
aScaleValue = (aCoords.Value(1) - aMinX) / aDelta;
827826
}
828-
catch (Standard_Failure const&)
827+
else
829828
{
830-
aScaleValue = 0;
829+
aScaleValue = 0.0;
831830
}
832831

833832
aScaleMap.Bind(anIter.Key(), aScaleValue);

0 commit comments

Comments
 (0)