Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace C++ exit(1) statements with exception handling #329

Merged
merged 8 commits into from
Oct 20, 2023
Merged

Conversation

anilbey
Copy link
Contributor

@anilbey anilbey commented Oct 20, 2023

When exit(1) is called within a C++ library that's being used by Python (e.g., through a Python API), it will terminate the entire process.

This PR replaces the exit(1) statements with exception handling. It further translates C++ exceptions to Python's built-in exceptions to enable graceful failures.

Given the frequent use of exit calls throughout eFEL – appearing in over 15 distinct locations, notably within the frequently used LinearInterpolation function – this update is expected to prevent approximately 95% of potential future crashes.

Related to #321 .

@codecov-commenter
Copy link

codecov-commenter commented Oct 20, 2023

Codecov Report

Attention: 25 lines in your changes are missing coverage. Please review.

Comparison is base (3ae9246) 57.04% compared to head (f11e36d) 57.05%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #329   +/-   ##
=======================================
  Coverage   57.04%   57.05%           
=======================================
  Files          29       30    +1     
  Lines        7825     7847   +22     
  Branches     3264     3273    +9     
=======================================
+ Hits         4464     4477   +13     
- Misses        846      850    +4     
- Partials     2515     2520    +5     
Files Coverage Δ
tests/test_basic.py 99.39% <ø> (ø)
tests/test_cppcore.py 100.00% <100.00%> (ø)
efel/cppcore/EfelExceptions.h 0.00% <0.00%> (ø)
efel/cppcore/Utils.h 71.42% <0.00%> (-7.52%) ⬇️
efel/cppcore/cfeature.cpp 23.30% <37.50%> (+0.61%) ⬆️
efel/cppcore/cppcore.cpp 54.02% <38.46%> (-1.33%) ⬇️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@anilbey anilbey marked this pull request as draft October 20, 2023 11:16
@anilbey anilbey changed the title throw runtime_error, rm exit(1) in featuretype&calcfeatures replace C++ exit(1) statements with exception handling Oct 20, 2023
efel/cppcore/cfeature.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@ilkilic ilkilic left a comment

Choose a reason for hiding this comment

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

Nice! Looks good to me

@anilbey anilbey marked this pull request as ready for review October 20, 2023 15:44
@anilbey anilbey merged commit ed1459c into master Oct 20, 2023
6 checks passed
@anilbey anilbey deleted the dependencies branch October 20, 2023 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants