fix: consistent error handling + exit codes in wallet balance check CLI [fj4WqyCCw3C5ShR1RfB7MoBPTpkRrBFYP1uT35g3MvT] - #8088
Open
waterWang wants to merge 1 commit into
Conversation
4 tasks
Contributor
|
Welcome to RustChain! Thanks for your first pull request. Before we review, please make sure:
Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150) A maintainer will review your PR soon. Thanks for contributing! |
…LI [fj4WqyCCw3C5ShR1RfB7MoBPTpkRrBFYP1uT35g3MvT]
Fixes two inconsistencies in tools/rustchain_wallet_cli.py (bounty #16253):
1. cmd_export: add explicit FileNotFoundError handling so missing
wallet returns EXIT_WALLET_NOT_FOUND (4) instead of the generic
EXIT_UNKNOWN_ERROR (6) from main()'s catch-all.
2. main(): Change lowercase 'Error: {e}' to uppercase 'ERROR: {e}'
to match the consistent uppercase style used by every other error
path in the CLI (cmd_balance, cmd_send, cmd_history, etc.).
3. Add 15 tests covering every failure path in cmd_balance, cmd_export,
cmd_send, cmd_history, _safe_json, and _safe_json_object — network
errors, 404, 500, malformed JSON, missing fields, missing wallet.
Closes Scottcjn#7889
Closes Scottcjn/rustchain-bounties#16253
waterWang
force-pushed
the
fix/consistent-error-handling-16253
branch
from
July 29, 2026 07:26
a625f50 to
32ee667
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Fixes two error-handling inconsistencies in
tools/rustchain_wallet_cli.py(bounty rustchain-bounties#16253).1.
cmd_export— explicit error handling for missing walletPreviously,
cmd_exportlet_load_keystore'sFileNotFoundErrorbubble up tomain()'s catch-all, which returned the genericEXIT_UNKNOWN_ERROR (6). Now it returnsEXIT_WALLET_NOT_FOUND (4)with a clear error message, matching the pattern used bycmd_send.2.
main()catch-all — consistent error message casingChanged
"Error: {e}"(lowercase) to"ERROR: {e}"(uppercase) to match the consistent uppercase style used by every other error path (cmd_balance,cmd_send,cmd_history,cmd_miners,cmd_epoch).3. Comprehensive test coverage (15 new tests)
Added
tests/test_wallet_cli_error_handling_16253.pycovering every failure path:_safe_jsonEXIT_BAD_RESPONSE (3)_safe_json_objectEXIT_BAD_RESPONSE (3)cmd_balanceEXIT_NETWORK_ERROR (2)cmd_balanceEXIT_WALLET_NOT_FOUND (4)cmd_balanceEXIT_BAD_RESPONSE (3)cmd_balanceEXIT_BAD_RESPONSE (3)cmd_balanceEXIT_BAD_RESPONSE (3)cmd_balancebalance_rtcalias (happy path)EXIT_SUCCESS (0)cmd_exportEXIT_WALLET_NOT_FOUND (4)cmd_historyEXIT_NETWORK_ERROR (2)cmd_historyEXIT_WALLET_NOT_FOUND (4)cmd_historyEXIT_BAD_RESPONSE (3)cmd_sendEXIT_WALLET_NOT_FOUND (4)cmd_sendEXIT_NETWORK_ERROR (2)Specific inconsistencies addressed (from #7889)
cmd_export: FileNotFoundError bubbled to main() catch-all → returned wrong exit code (6 instead of 4)main(): lowercase "Error: {e}" inconsistent with uppercase "ERROR: " everywhere else--helpepilogVerification
python3 -m pytest tests/test_wallet_cli_39.py tests/test_wallet_cli_error_handling_16253.py --noconftest -v→ 31/31 passedCloses #7889
Closes Scottcjn/rustchain-bounties#16253