venkateshwaracholan opened a new pull request, #4399:
URL: https://github.com/apache/polaris/pull/4399
## Summary
Replace generic `Exception` usage across the Python CLI with typed
`CliError` handling and explicit exit codes.
The Python CLI was previously raising plain `Exception` for most validation,
configuration, and runtime failures. This made error reporting inconsistent and
prevented proper exit code handling for user-facing CLI errors.
This change introduces a dedicated `CliError` exception type with explicit
exit codes:
* `CLI_USAGE_EXIT_CODE = 2` for validation/configuration/usage errors
* `CLI_ERROR_EXIT_CODE = 1` for runtime/API failures
Also updates abstract command methods to use `NotImplementedError` and
improves exception handling in the main CLI entrypoint.
## Changes
* Added `client/python/apache_polaris/cli/exceptions.py`
* Replaced generic `raise Exception(...)` with `CliError` across CLI command
modules
* Updated `polaris_cli.py` with explicit exception handling and exit code
behavior
* Updated abstract command methods to raise `NotImplementedError`
* Added unit tests covering:
* `CliError` behavior
* parser validation failures
* CLI exit behavior
* Updated `CHANGELOG.md`
## Before vs After
### Before
```bash
raise Exception("Failed to get access token")
```
### After
* Clearer user-facing error messages
* Proper CLI exit codes
* More consistent validation handling
* Better maintainability and testability
## Testing
```bash
cd client/python
pytest tests/test_cli_exceptions.py -vv
pytest tests/test_parser_basic.py -vv
```
## Checklist
* [x] ๐ก๏ธ Don't disclose security issues! (contact
[[[email protected]](mailto:[email protected])](mailto:[email protected]))
* [x] ๐ Clearly explained why the changes are needed
* [x] ๐งช Added/updated tests with good coverage
* [x] ๐ก Added comments for complex logic
* [x] ๐งพ Updated CHANGELOG.md
* [x] ๐ No documentation changes needed
--
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]