mason: refactor error propagation from masonInit and masonNew #28256
+81
−85
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.
Overview
This PR refactors error handling in the Mason package manager so internal functions (
masonInit,masonNew) propagateMasonErrorto the top-level CLI handler instead of catching and callingexit(1)locally. This centralizes error-to-exit behavior, improves testability, and preserves user-visible behavior.Changes
tools/mason/MasonInit.chpl: remove localtry! { ... } catch e: MasonError { ... exit(1); }wrapper; letMasonErrorpropagatetools/mason/MasonNew.chpl: remove local try/catch wrapper soMasonErrorpropagates (applied earlier)test/mason/masonInit/masonInitTest3.chpl: updated to catchMasonErrorand printe.message(); addeduse MasonUtils;andproc main() throwstest/mason/masonNewBadName.chpl: updated to catchMasonErrorand printe.message()(applied earlier)Rationale
Centralizing error handling at the top-level CLI (
tools/mason/mason.chpl) provides:Local testing
$ ./util/start_test test/mason
Test Summary: #Successes = 112 | #Failures = 0 | #Futures = 0 | #Warnings = 0
Branch: mason/issue-28120-fix-mason-error-handling
Commit: 229e4c8
Environment: macOS, CHPL_HOME=/Users/tausiffhussainum/workspace/open-source/chapel
Notes
Signed-off-by: Tausif Mujawar <[email protected]>Request for reviewers
Please review the above files and the respective test cases . The change is intended to be behavior-preserving for end users (error messages + exit codes continue to be handled by the top-level CLI). Please provide any feedback that can improve the fix. I have made changes in 2 files and based on the feedback i would incrementally make changes to other files as well to use the same pattern to handle errors. @jabraham17 Can you please review the PR.