- Notifications
You must be signed in to change notification settings - Fork 197
helper functions for Filesystem error handling #1015
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
| Thanks for this PR @wassup05. Question: is there a reason for using UPPER_CASE ? The style guide promotes snake_case for procedures and constants. |
| Oh no, It was just because it was an error and I felt it was better to emphasize that, but I'll change it |
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.
Pull Request Overview
This PR introduces two helper functions fs_error and fs_error_code to simplify filesystem error handling in the stdlib_system module. These functions provide convenient ways to create state_type objects with the STDLIB_FS_ERROR flag set.
- Adds
fs_errorfunction that accepts up to 20 optional arguments and creates a filesystem error state - Adds
fs_error_codefunction that prefixes an error code to the message and accepts up to 19 additional arguments - Includes comprehensive tests, documentation, and example code
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/stdlib_system.F90 | Implements the two new helper functions and adds required imports |
test/system/test_filesystem.f90 | Adds unit tests for both helper functions |
doc/specs/stdlib_system.md | Documents the new functions with detailed specifications |
example/system/example_fs_error.f90 | Provides usage examples for both functions |
example/system/CMakeLists.txt | Registers the new example in the build system |
Comments suppressed due to low confidence (2)
test/system/test_filesystem.f90:25
- The subroutine name
test_fs_erroris inconsistent with the test nametest_FS_ERRORused innew_unittest. Consider renaming totest_FS_ERRORfor consistency.
subroutine test_fs_error(error) doc/specs/stdlib_system.md:472
- The syntax example shows
fs_errorbut should befs_error_codesince this is documenting thefs_error_codefunction.
`err = fs_error(code [, a1,a2,a3,a4...... a19])`
jalvesz left a comment
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.
Thanks @wassup05 LGTM
perazz left a comment
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.
Thanks for this PR @wassup05. I added a few comments.
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.
LGTM, thank you @wassup05. With two approvals, I will merge this one.
Functions added are:
fs_error: just sets theflagofstate_typetoSTDLIB_FS_ERRORand passes the remaining 20 arguments to itfs_error_code: sets theflagas above and also prefixes thecode(integerargument) accordingly.I tried using an
interfaceblock to handle both of these together, but that introduces ambiguity for the compiler.Could make
codeanoptionalargument and depending on if it's present or not pass 18 or 20 arguments tostate_typebut I feel that the 2 unused arguments in that case would not be correct.Inspired from @perazz in #1006 (comment)