Situation
Sonar complains about CliException being a checked exception (rule S1160: "Checked exceptions should not be thrown"). In modern Java design, unchecked exceptions are often preferred for situations where the caller is not expected to recover, such as CLI argument validation errors where the program must terminate after reporting the error. Currently, CliException extends Exception, forcing many method signatures to declare throws CliException.
Implementation Hints
- Modify
org.itsallcode.openfasttrace.core.cli.CliException to extend RuntimeException instead of Exception.
- Remove redundant
throws CliException clauses from method signatures in CommandLineInterpreter, CliStarter, and other relevant classes.
- Keep the
@throws CliException Javadoc where useful for documentation of the API contract.
- Ensure the centralized error handling in
CliStarter.mainDelegate continues to catch CliException to report errors to the user gracefully.
Acceptance Criteria
CliException is a RuntimeException.
- No more Sonar S1160 warnings for
CliException.
- The CLI still gracefully handles invalid arguments and prints the error message to
System.err as before.
mvn verify passes, including all tests and self-trace checks.
Situation
Sonar complains about
CliExceptionbeing a checked exception (rule S1160: "Checked exceptions should not be thrown"). In modern Java design, unchecked exceptions are often preferred for situations where the caller is not expected to recover, such as CLI argument validation errors where the program must terminate after reporting the error. Currently,CliExceptionextendsException, forcing many method signatures to declarethrows CliException.Implementation Hints
org.itsallcode.openfasttrace.core.cli.CliExceptionto extendRuntimeExceptioninstead ofException.throws CliExceptionclauses from method signatures inCommandLineInterpreter,CliStarter, and other relevant classes.@throws CliExceptionJavadoc where useful for documentation of the API contract.CliStarter.mainDelegatecontinues to catchCliExceptionto report errors to the user gracefully.Acceptance Criteria
CliExceptionis aRuntimeException.CliException.System.erras before.mvn verifypasses, including all tests and self-trace checks.