-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
head: improve error mgmt. #7408
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This pull request improves error management for the head utility by providing more descriptive error messages and ensuring consistent error mapping during output operations.
- Updates the error message in the test to include context about standard output errors
- Introduces a new helper function, map_stdout_error, to wrap and format errors consistently
- Applies map_stdout_error mapping to both copy and flush operations in relevant functions
Reviewed Changes
File | Description |
---|---|
tests/by-util/test_head.rs | Updates expected error message for write failures |
src/uu/head/src/head.rs | Adds map_stdout_error function and applies it to error handling calls |
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
tests/by-util/test_head.rs:809
- The updated error message now includes additional context regarding standard output errors. Verify that this message is consistent with error wording elsewhere in the application.
.stderr_contains("error writing 'standard output': No space left on device");
src/uu/head/src/head.rs:246
- [nitpick] Consider inlining map_stdout_error (e.g. with #[inline]) to potentially reduce function call overhead for this trivial error mapping function.
fn map_stdout_error(err: io::Error) -> io::Error {
GNU testsuite comparison:
|
GNU testsuite comparison:
|
And provide more details than GNU Should fix tests/head/head-write-error
And provide more details than GNU
Should fix tests/head/head-write-error