refactor: move ExitException and exit codes out of cli package - #2602
Conversation
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Move ExitException from dev.jbang.cli to dev.jbang with exit code
constants and factory methods directly on the class:
throw ExitException.invalidInput("bad input");
throw ExitException.unexpectedState("missing file", cause);
throw ExitException.genericError(cause);
throw ExitException.internalError("should not happen");
Constants (EXIT_OK, EXIT_GENERIC_ERROR, etc.) live on ExitException.
BaseCommand retains deprecated delegate constants for backward compat.
This breaks the only reverse dependency (core -> cli), making a future
jbang-core library split straightforward.
All 840 tests pass (1 pre-existing unrelated failure).
29a5b08 to
c88852c
Compare
|
wdyt @quintesse, right direction? we could go add archunit to ensure this cross dep dont happen again. |
b8b664d to
c88852c
Compare
|
LGTM! 👍 |
|
Click the review approve button please. Then I don't have to break GitHub ui rules all the time :) |
I was on my phone and didn't want to go through 3 levels of pages and dialogs to just give a 👍 😉 |
What
Moves
ExitExceptionfromdev.jbang.clitodev.jbangwith exit code constants and factory methods on the class itself.Why
ExitExceptionis jbang's universal error type — used in 30+ files across catalog, dependencies, source, util, net, and spi packages. It just happened to live indev.jbang.clibecause that's where it started. This created the only reverse dependency (core → cli) blocking a cleanjbang-corelibrary split (see #1128).Changes
dev.jbang.ExitException— moved fromdev.jbang.cli, now contains both exit code constants and factory methodsdev.jbang.cli.ExitException— deleted (no compat shim needed)BaseCommand— retains deprecated delegate constants for backward compatConstants on ExitException
Factory methods
What this enables
With this change, the non-cli packages have zero imports from
dev.jbang.cli. A future Gradle multi-project split intojbang-core(105 files, 18K LoC) andjbang-cli(38 files, 8K LoC) would be a pure build config change — no source moves needed.Options for #1128 going forward
jbang-core(plugin SDK, IDE integration)java-library+apivsimplementation