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

rust: support rich errors #769

Merged
merged 5 commits into from
Apr 9, 2021
Merged

rust: support rich errors #769

merged 5 commits into from
Apr 9, 2021

Conversation

axic
Copy link
Member

@axic axic commented Mar 23, 2021

Depends on #772.

bindings/rust/src/lib.rs Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Mar 23, 2021

Codecov Report

Merging #769 (6f18680) into master (8dfd3c1) will increase coverage by 0.04%.
The diff coverage is 100.00%.

❗ Current head 6f18680 differs from pull request most recent head 3da0019. Consider uploading reports for the commit 3da0019 to get more accurate results

@@            Coverage Diff             @@
##           master     #769      +/-   ##
==========================================
+ Coverage   99.19%   99.23%   +0.04%     
==========================================
  Files          77       77              
  Lines       11893    11929      +36     
==========================================
+ Hits        11797    11838      +41     
+ Misses         96       91       -5     
Flag Coverage Δ
rust 99.87% <100.00%> (+<0.01%) ⬆️
spectests 90.54% <ø> (-0.01%) ⬇️
unittests 99.19% <ø> (+0.04%) ⬆️

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

Impacted Files Coverage Δ
bindings/rust/src/lib.rs 99.87% <100.00%> (+<0.01%) ⬆️
lib/fizzy/instantiate.cpp 100.00% <0.00%> (ø)
test/unittests/capi_test.cpp 99.88% <0.00%> (ø)
lib/fizzy/capi.cpp 97.83% <0.00%> (+0.29%) ⬆️
test/utils/fizzy_c_engine.cpp 100.00% <0.00%> (+3.33%) ⬆️
test/utils/fizzy_engine.cpp 100.00% <0.00%> (+3.77%) ⬆️

bindings/rust/src/lib.rs Outdated Show resolved Hide resolved
@axic axic force-pushed the rust-rich-error branch 3 times, most recently from 90feba2 to 21ef74d Compare March 24, 2021 12:47
@gumb0 gumb0 force-pushed the rich-error-reporting branch 6 times, most recently from f04fd67 to d02dde6 Compare March 25, 2021 12:00
@axic axic changed the base branch from rich-error-reporting to master March 31, 2021 14:56
@axic axic force-pushed the rust-rich-error branch 4 times, most recently from 8bc7c36 to b1a4b88 Compare March 31, 2021 17:13
@axic axic requested review from gumb0 and chfast and removed request for gumb0 March 31, 2021 17:14
@axic axic marked this pull request as ready for review March 31, 2021 17:14
bindings/rust/src/lib.rs Outdated Show resolved Hide resolved
bindings/rust/src/lib.rs Outdated Show resolved Hide resolved
)
};
if ret {
debug_assert!(err.code() == 0);
Copy link
Member Author

Choose a reason for hiding this comment

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

These assertions show the current error reporting system is not prefect, as there are two ways to tell failure, error code or the return value.

Copy link
Collaborator

@gumb0 gumb0 Mar 31, 2021

Choose a reason for hiding this comment

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

For validate theoretically we could return error code instead of bool (plus optional error message), but for parse and instantiate it seems inevitable: we have to return a pointer to module / instance in any case, and when we also return an error code this pointer is going to be NULL.

Copy link
Member Author

@axic axic Mar 31, 2021

Choose a reason for hiding this comment

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

Do we want to add assertions into the capi for this? Or at least extend the tests? And document it?

These debug_asserts here act like the C assert, they are not part of a release build. Happy to keep them though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want to add assertions into the capi for this? Or at least extend the tests? And document it?

Tests already have checks for both return value and error for both failure and success cases.

Assertions in C API - not sure where and which ones (it seems kind of obvious there that error is set when false or nullptr is returned)

Document it - something likeReturned error code is FIZZY_SUCCESS iff return value is true? Sounds somewhat obvious, too...

Copy link
Member Author

@axic axic Apr 8, 2021

Choose a reason for hiding this comment

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

I guess documentation is fine just saying that error code must be FIZZY_SUCCESS if a pointer is returned and must NOT be FIZZY_SUCCESS otherwise? Basically we want to give indication to the user that they do not need to check both.

@axic axic requested a review from gumb0 April 7, 2021 18:12
@axic axic merged commit b8f6e50 into master Apr 9, 2021
@axic axic deleted the rust-rich-error branch April 9, 2021 17:24
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