[Chapel Merge] Refactored error propoagation in masonsystem,update and publish files

Branch: refs/heads/main
Revision: d5b6f061f2b43e73ccad5d0e4d792bf625f1123d
Author: tausiffmujawar
Link: https://github.com/chapel-lang/chapel/pull/28339
Log Message:
Refactored error propoagation in masonsystem,update and publish files (#28339)

Overview

This PR continues the refactor of error handling in the Mason package
manager. Internal functions now propagate MasonError to the top-level
CLI handler instead of catching and calling exit(1) locally. This
centralizes error-to-exit behavior, improves testability, and preserves
user-visible behavior.

Changes

[Mason.chpl]

  • Centralized error handling: subcommands now propagate MasonError to
    the CLI handler, which is responsible for user-facing error reporting.
  • Removed exit(1) from subcommand error handling; now uses throw for
    MasonError.
  • Fixed extra brace and resolved merge conflict markers.

[MasonUpdate.chpl]

  • Combined changes to support both error propagation (throws) and the
    force argument for updateLock.
  • updateLock now has the signature: throws and force=false.
  • Ensured all error-prone logic is properly marked with throws.

[MasonExample.chpl]

  • Marked printAvailableExamples() with throws to comply with Chapel’s
    try/catch requirements.
  • Now propagates MasonError instead of handling exit locally.

[Other Mason source files: MasonSystem.chpl, MasonPublish.chpl,
etc.]

  • Updated to propagate errors and match the new error handling pattern.
  • Ensured all functions using try/catch or throwing errors are marked
    with throws.

[Test files under test/mason] :

[mason-chpl-version-update.chpl]
[masonNewModule.chpl]
[masonNewTest.chpl]
[masonUpdateTest.chpl]

  • Reviewed above test files to ensure they catch MasonError and match
    the new error propagation pattern.

[docPkg.chpl]

  • The mason-doc tests were updated to reflect corrected error
    propagation. Previously, missing generated documentation files
    (Pkg.rst.txt, SubPkg.rst.txt, and in the withAuthor case index.html)
    were reported as successes. After the refactor, these failures are now
    surfaced correctly. The .good files were updated to match the test logic
    and actual filesystem state; no MasonDoc behavior was relaxed or
    changed.

[masonHelpTests.good]

  • The '--[no-]update' flag is no longer shown in this help output
    because it is not registered for this command after the refactor. This
    change is indirect—no option was removed explicitly—but the help text
    now reflects only supported flags. The .good file was updated
    accordingly.

[publishOffline.chpl]

  • After refactoring 'MasonPublish' to throw MasonError instead of
    calling 'exit(1)', the offline publish test began surfacing an uncaught
    exception. The test now catches MasonError and prints only the error
    message, preserving the original user-visible behavior. An empty
    catch-all is included to satisfy Chapel’s requirement for 'try' in a
    non-throwing 'main'

Rationale

Centralizing error handling at the top-level CLI (Mason.chpl) provides:

  • Unit testing: Internal functions can be tested without process
    exit.
  • Consistent error reporting: Single exit-to-user mapping.
  • Separation of concerns: Internal code handles logic; CLI handles
    user-facing exit behavior.

Local testing

$ ./util/start_test test/mason
[Test Summary - 260125.121934]
[Summary: #Successes = 114 | #Failures = 0 | #Futures = 0 | #Warnings =
0 ]
[Summary: #Passing Suppressions = 0 | #Passing Futures = 0 ]
[END]

Branch: mason/issue-28120-fix-third-PR
Environment: macOS,
CHPL_HOME=/Users/tausiffhussainum/workspace/open-source/chapel

Notes

All commits include DCO sign-off:
Signed-off-by: Tausif Mujawar tausiff-hussain-umarsab.mujawar@hpe.com

This PR continues work on: Refactor mason error handling for better unit
testing #28120

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 and
exit codes continue to be handled by the top-level CLI). Please provide
any feedback that can improve the fix.

[Contributed by @tausiffmujawar, Reviewed and merged by @jabraham17]

Compare: Comparing 561023684f75a774871850bff48f32135b57b8ff...bc4cfc9924a74e20d27e1b93516b019da1bc222f · chapel-lang/chapel · GitHub

Diff:
M test/mason/mason-doc/docPkg.chpl
M test/mason/mason-offline/publishOffline.chpl
M test/mason/mason-update-toml-error/mason-chpl-version-update.chpl
M test/mason/masonNewModule.chpl
M test/mason/masonNewTest.chpl
M test/mason/masonUpdateTest.chpl
M tools/mason/MasonExample.chpl
M tools/mason/MasonPublish.chpl
M tools/mason/MasonSystem.chpl
https://github.com/chapel-lang/chapel/pull/28339.diff