gnodet opened a new pull request, #22163:
URL: https://github.com/apache/camel/pull/22163
## Summary
Camel JBang commands used three inconsistent patterns for reporting errors
to the user:
1. `printer().printErr()` -- the correct approach, uses the Printer
abstraction with `ERROR:` prefix
2. `printer().println("error message")` / `printer().printf("error
message")` -- writes to stdout instead of stderr, no consistent error prefix
3. `throw new RuntimeException(e)` -- dumps raw stack traces, poor UX for
CLI users
This PR standardizes pattern 2 to use `printErr()` instead. All
`printer().println()` and `printer().printf()` calls that output error-like
messages (not found, cannot, invalid format, etc.) are replaced with
`printer().printErr()`.
Pattern 3 (`throw new RuntimeException`) is **not** addressed here -- the
cases found are either in internal utility code (CloneNotSupportedException in
Row classes, file copy helpers) or inside lambdas where returning an exit code
is not possible. Those warrant separate consideration.
## Affected commands
- **InfraRun** -- service not found messages
- **InfraLog** -- log not found message
- **Run** -- working directory creation failure, background mode not
supported for Quarkus/Spring Boot
- **UpdateRun** -- CamelUpdateException and DownloadException handling
- **ConfigGet** -- key not found
- **CatalogDoc** -- resource/component/kamelet not found (including "did you
mean" suggestions)
- **CamelSendAction** -- header format validation, connection details read
failure
- **TransformMessageAction** -- header and option format validation
- **CamelReceiveAction** -- error starting to receive messages
- **EvalExpressionCommand** -- header format validation
- **VersionList** -- download error
- **DependencyRuntime** -- pom.xml not found
- **PluginDelete** -- plugin not found in configuration
## Tests
Updated `ConfigGetTest` and `PluginDeleteTest` to expect the `ERROR:` prefix
from `printErr()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]