Skip to content

Refactor error handling and improve test logging for installers - #989

Merged
HarithaVattikuti merged 8 commits into
actions:mainfrom
chiranjib-swain:improve-java-error-messaging
Apr 13, 2026
Merged

Refactor error handling and improve test logging for installers#989
HarithaVattikuti merged 8 commits into
actions:mainfrom
chiranjib-swain:improve-java-error-messaging

Conversation

@chiranjib-swain

@chiranjib-swain chiranjib-swain commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Description:
This PR standardizes the “version not found” error handling across Java distribution installers by introducing a shared helper in JavaBase. It also updates installer and caching tests to align with the new message format and reduces noisy core.error output during test runs.

Related issue:
#977, #978

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

Copilot AI review requested due to automatic review settings March 18, 2026 05:27
@chiranjib-swain
chiranjib-swain requested a review from a team as a code owner March 18, 2026 05:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 standardizes “version not found” error handling across Java distribution installers by introducing a shared helper on JavaBase, and updates installer/caching tests to use the new message format while reducing noisy core.error output during test runs.

Changes:

  • Added JavaBase.createVersionNotFoundError(...) to generate consistent, context-rich error messages (with optional available-versions truncation).
  • Refactored multiple distribution installers to throw the standardized error instead of bespoke strings.
  • Updated Jest suites to align assertions with the new messages and to consistently mock core.error to suppress test log noise.

Reviewed changes

Copilot reviewed 33 out of 34 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/distributions/base-installer.ts Adds createVersionNotFoundError helper for standardized errors.
src/distributions/adopt/installer.ts Uses the new helper when no satisfied version is found.
src/distributions/corretto/installer.ts Uses the new helper when no satisfied version is found.
src/distributions/dragonwell/installer.ts Uses the new helper when no satisfied version is found.
src/distributions/graalvm/installer.ts Switches to the helper for some “not found” paths and appends a GraalVM URL hint on 404.
src/distributions/jetbrains/installer.ts Uses the new helper when no satisfied version is found.
src/distributions/liberica/installer.ts Uses the new helper when no satisfied version is found.
src/distributions/microsoft/installer.ts Uses the new helper when no satisfied version is found (includes manifest versions).
src/distributions/oracle/installer.ts Uses the new helper when no satisfied version is found.
src/distributions/sapmachine/installer.ts Uses the new helper when no satisfied version is found.
src/distributions/semeru/installer.ts Uses the new helper and adds platform context to the error.
src/distributions/temurin/installer.ts Uses the new helper when no satisfied version is found.
src/distributions/zulu/installer.ts Uses the new helper when no satisfied version is found.
dist/setup/index.js Updates the compiled distribution bundle to reflect source changes.
tests/distributors/adopt-installer.test.ts Mocks core.error to suppress logs during tests.
tests/distributors/base-installer.test.ts Updates version-not-found expectations and adds unit tests for the helper.
tests/distributors/corretto-installer.test.ts Mocks core.error to suppress logs during tests.
tests/distributors/dragonwell-installer.test.ts Updates error expectations and mocks core.error.
tests/distributors/graalvm-installer.test.ts Updates error expectations and removes assertions tied to old core.error logging behavior.
tests/distributors/jetbrains-installer.test.ts Mocks core.error to suppress logs during tests.
tests/distributors/liberica-installer.test.ts Updates error expectations and mocks core.error.
tests/distributors/liberica-linux-installer.test.ts Updates error expectations and mocks core.error.
tests/distributors/liberica-windows-installer.test.ts Updates error expectations and mocks core.error.
tests/distributors/local-installer.test.ts Mocks core.error to suppress logs during tests.
tests/distributors/microsoft-installer.test.ts Mocks core.error to suppress logs during tests.
tests/distributors/oracle-installer.test.ts Mocks core.error to suppress logs during tests.
tests/distributors/sapmachine-installer.test.ts Updates error expectations and mocks core.error.
tests/distributors/semeru-installer.test.ts Mocks core.error to suppress logs during tests.
tests/distributors/temurin-installer.test.ts Mocks core.error to suppress logs during tests.
tests/distributors/zulu-installer.test.ts Updates error expectations and mocks core.error.
tests/distributors/zulu-linux-installer.test.ts Updates error expectations and mocks core.error.
tests/distributors/zulu-windows-installer.test.ts Updates error expectations and mocks core.error.
tests/cache.test.ts Mocks core.error and strengthens cleanup of Jest mocks between tests.
tests/cleanup-java.test.ts Mocks core.error and strengthens cleanup of Jest mocks between tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/distributions/base-installer.ts Outdated