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

add is_error and fix error handling #1061

Merged
merged 11 commits into from Oct 21, 2021

Conversation

darbyjohnston
Copy link
Contributor

Fixes #1060

These changes fix the error handling in Composition::child_at_time(), Composition::children_in_range(), Composition::children_if(), and SerializableCollection::children_if() to properly check the error_status and return from the function.

I also added an additional Python test for the various options to children_if()/each_child(), though it might not be necessary if it doesn't increase test coverage. I was hoping to test the various error conditions that were fixed, though it's not obvious how to trigger them since error_status is passed down to so many different functions.

@codecov-commenter
Copy link

codecov-commenter commented Sep 6, 2021

Codecov Report

Merging #1061 (965848d) into master (64fcb60) will decrease coverage by 0.13%.
The diff coverage is 44.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1061      +/-   ##
==========================================
- Coverage   86.32%   86.19%   -0.14%     
==========================================
  Files         191      191              
  Lines       19004    19041      +37     
  Branches     2105     2105              
==========================================
+ Hits        16406    16412       +6     
- Misses       2052     2083      +31     
  Partials      546      546              
Flag Coverage Δ
unittests 86.19% <44.50%> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/opentime/rationalTime.h 89.79% <ø> (ø)
src/opentimelineio/clip.cpp 79.31% <0.00%> (-5.88%) ⬇️
src/opentimelineio/composable.cpp 69.23% <0.00%> (-2.77%) ⬇️
src/opentimelineio/composable.h 100.00% <ø> (ø)
src/opentimelineio/composition.h 88.88% <0.00%> (+1.93%) ⬆️
src/opentimelineio/errorStatus.cpp 42.30% <ø> (ø)
src/opentimelineio/imageSequenceReference.h 62.50% <ø> (ø)
src/opentimelineio/item.h 100.00% <ø> (ø)
src/opentimelineio/serializableCollection.cpp 70.73% <0.00%> (-3.63%) ⬇️
src/opentimelineio/serializableCollection.h 86.66% <0.00%> (-2.23%) ⬇️
... and 28 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 64fcb60...965848d. Read the comment docs.

Copy link
Collaborator

@meshula meshula left a comment

Choose a reason for hiding this comment

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

The reason the null checks were on the error_status was because we pass in a pointer, that can be null, which causes crashes upon dereference. Clearly that's confusing as there's ambiguity as to whether the error status is supposed to be checked, or if the error status is merely a place to write.

This code is meant to write to error_status, if error_status was applied. Not, if error_status pointer was supplied return as if an error occurred.

I believe the real issue, to @gfgit's original review, is that we are using a C style idiom in a C++ interface. Having a pointer to a place to store any errors in the interface is the root source of the issue. I'm open to a new interface proposal.

@darbyjohnston darbyjohnston marked this pull request as draft September 10, 2021 00:09
Copy link
Collaborator

@meshula meshula left a comment

Choose a reason for hiding this comment

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

Huge thanks for grinding this through!

Could I request one more reviewer please? There's a lot to read here, and it would be good for someone else to also check.

@darbyjohnston darbyjohnston marked this pull request as ready for review September 29, 2021 00:23
@jminor jminor added this to the Public Beta 14 milestone Oct 11, 2021
Copy link
Collaborator

@ssteinbach ssteinbach left a comment

Choose a reason for hiding this comment

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

Given that the overwhelming number of if() statements are !...is_ok(error_status), would it make more sense to provide ErrorStatus::is_error?

if (ErrorStatus::is_error(error_status)) {...}
(this would just be to test positives rather than negatives).

We could additionally promote this to a top level function or macro:
IS_ERROR(error_status)
is_error(error_status)

Rather than one scope on the type.

Apologies for the slow/late response!

src/opentime/rationalTime.cpp Show resolved Hide resolved
Copy link
Collaborator

@ssteinbach ssteinbach left a comment

Choose a reason for hiding this comment

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

This looks great! one REALLY small change to a comment and I think we can land this! Thanks @darbyjohnston!

src/opentimelineio/errorStatus.h Outdated Show resolved Hide resolved
src/opentimelineio/item.cpp Show resolved Hide resolved
Change comment to include *
@ssteinbach
Copy link
Collaborator

Looks great, thanks @darbyjohnston!

@ssteinbach ssteinbach merged commit 31b0e8d into AcademySoftwareFoundation:master Oct 21, 2021
@ssteinbach ssteinbach changed the title Error fixes add is_error and fix error handling Oct 21, 2021
@darbyjohnston darbyjohnston deleted the error_fixes branch November 27, 2021 18:47
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.

Error handling fixes
5 participants