Skip to content

Coding - Reducing relying on exceptions#676

Merged
dpasukhi merged 1 commit intoOpen-Cascade-SAS:IRfrom
dpasukhi:exception_avoid
Aug 16, 2025
Merged

Coding - Reducing relying on exceptions#676
dpasukhi merged 1 commit intoOpen-Cascade-SAS:IRfrom
dpasukhi:exception_avoid

Conversation

@dpasukhi
Copy link
Copy Markdown
Member

Updated PCDM_ReadWriter_1.cxx to avoid exceptions in reading reference counter and version.
Updated XSDRAWSTL to avoid null division checks.

Updated PCDM_ReadWriter_1.cxx to avoid exceptions in reading reference counter and version.
Updated XSDRAWSTL to avoid null division checks.
@dpasukhi dpasukhi added this to the Release 8.0 milestone Aug 16, 2025
@dpasukhi dpasukhi requested a review from Copilot August 16, 2025 11:41
@dpasukhi dpasukhi self-assigned this Aug 16, 2025
@dpasukhi dpasukhi added 2. Enhancement New feature or request 1. Coding Coding rules, trivial changes and misprints labels Aug 16, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR aims to improve error handling by replacing exception-based control flow with explicit condition checks. The changes reduce reliance on exceptions for predictable error conditions, which can improve performance and code clarity.

  • 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

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/ApplicationFramework/TKCDF/PCDM/PCDM_ReadWriter_1.cxx Replaced exception handling with explicit integer validation checks for reading reference counter and document version
src/Draw/TKXSDRAWSTL/XSDRAWSTL/XSDRAWSTL.cxx Added division-by-zero protection using precision comparison instead of exception handling

if (aToken.IsIntegerValue())
{
OCC_CATCH_SIGNALS theReferencesCounter = refUserInfo(i).Token(" ", 2).IntegerValue();
theReferencesCounter = aToken.IntegerValue();
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name 'aToken' follows OCCT naming conventions correctly, but consider using a more descriptive name like 'aCounterToken' to better express its purpose in this context.

Copilot uses AI. Check for mistakes.
if (aToken.IsIntegerValue())
{
OCC_CATCH_SIGNALS theVersion = refUserInfo(i).Token(" ", 2).IntegerValue();
theVersion = aToken.IntegerValue();
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the reference counter case, consider using a more descriptive variable name like 'aVersionToken' instead of the generic 'aToken' for better code clarity.

Copilot uses AI. Check for mistakes.
@dpasukhi dpasukhi merged commit d1b00bf into Open-Cascade-SAS:IR Aug 16, 2025
23 checks passed
@dpasukhi dpasukhi deleted the exception_avoid branch August 16, 2025 12:55
@github-project-automation github-project-automation bot moved this from Todo to Done in Maintenance Aug 16, 2025
dpasukhi added a commit that referenced this pull request Sep 6, 2025
- 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
dpasukhi added a commit that referenced this pull request Sep 6, 2025
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1. Coding Coding rules, trivial changes and misprints 2. Enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants