improve error handling consistency#525
Conversation
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #525 +/- ##
==========================================
+ Coverage 85.10% 85.49% +0.38%
==========================================
Files 142 142
Lines 3645 3653 +8
Branches 626 629 +3
==========================================
+ Hits 3102 3123 +21
+ Misses 326 313 -13
Partials 217 217
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 3 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Add two tests in PHLEX_REGISTER_PROVIDERS that call s.provide() with bad return-type annotations, covering the `if (!annotations_to_strings(...))` return-nullptr path in sc_provide (modulewrap.cpp lines 1197-1198) that was flagged by CodeCov on PR Framework-R-D#525: - Union type (List[int]|Dict[int,int]) triggers the !norm path - Surrogate string triggers the !ann (PyUnicode_AsUTF8 failure) path Agent-Logs-Url: https://github.com/Framework-R-D/phlex/sessions/ed722823-d51b-4db7-868b-51cfafe6a548 Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
greenc-FNAL
left a comment
There was a problem hiding this comment.
LGTM—I assume return "" vs return nullptr was a conscious choice?
I asked Copilot to try to improve the test coverage for the flagged lines missing coverage here, and it came up with 8c28888: feel free to cherry-pick, take inspiration from, or ignore as you prefer.
Yes; |
…e-codecov test: cover sc_provide annotation error paths in pyprovide.py
Originally noticed by @greenc-FNAL, see here: #495 (comment), there are cases in the current code where a C++ exception is thrown where to code can still be reasonably be expected to return to Python for error handling. This PR removes two cases of throwing C++ exceptions in favor of setting Python exceptions and returning
nullptr.