Enhance error handling in bundle extractor with ferror() and errno diagnostics #120676
+82
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances error handling in the
extract()
function ofsrc/native/corehost/bundle/extractor.cpp
to provide more detailed diagnostics when bundle extraction fails due to I/O errors.Changes
Added Headers
<cerrno>
- For errno constant definitions<cstring>
- For strerror() function to get human-readable error messagesEnhanced fwrite() Error Handling
Added
ferror()
checks and specific errno diagnostics in two write paths:Both paths now check for and report specific error conditions:
ENOSPC
- No space left on deviceEDQUOT
- Disk quota exceeded (with#ifdef
guard for platform compatibility)EIO
- I/O errorEFBIG
- File too largeAdded fclose() Return Value Checking
Previously,
fclose()
was called without checking its return value. Now the code:fclose()
returns non-zero (indicating failure)Benefits
This enhancement significantly improves diagnostics for bundle extraction failures by:
strerror()
#ifdef EDQUOT
guards since EDQUOT is not available on all platformsExample Error Output
Before:
After:
This makes it much easier to diagnose and resolve bundle extraction issues in production environments.
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.