Skip to content

fix: improve consistent error handling and exit codes in wallet balance script#8024

Merged
Scottcjn merged 4 commits into
Scottcjn:mainfrom
JHON12091986:feat/consistent-wallet-balance-errors
Jul 21, 2026
Merged

fix: improve consistent error handling and exit codes in wallet balance script#8024
Scottcjn merged 4 commits into
Scottcjn:mainfrom
JHON12091986:feat/consistent-wallet-balance-errors

Conversation

@JHON12091986

Copy link
Copy Markdown
Contributor

Summary

This PR improves the error handling consistency in the wallet balance check script (tools/rustchain_wallet_cli.py) by adding standardized exit codes and specific error handling for all failure paths.

Changes

  • Add EXIT_SUCCESS, EXIT_USAGE_ERROR, EXIT_NETWORK_ERROR, EXIT_BAD_RESPONSE, EXIT_WALLET_NOT_FOUND, EXIT_AUTH_ERROR, EXIT_UNKNOWN_ERROR codes
  • Improve cmd_balance() with specific error handling for:
    • Network errors (timeout, connection refused)
    • HTTP 404 (wallet not found)
    • Non-200 responses
    • Malformed JSON responses
    • Missing "amount_rtc" field
  • Add proper error messages to stderr for all failure paths
  • No behavior change on happy path

Testing

  • Verified happy path returns balance with exit code 0
  • Verified network error returns exit code 2 with stderr message
  • Verified 404 returns exit code 4 with stderr message

Closes

Closes Rustchain#7889
Closes #16253

Bounty

RTC wallet: RTC921ffc4353965fe09d946c1d826e398f0437d97e
Miner ID: JHON12091986

…ce script

- Add EXIT_SUCCESS, EXIT_USAGE_ERROR, EXIT_NETWORK_ERROR, EXIT_BAD_RESPONSE, EXIT_WALLET_NOT_FOUND codes
- Improve cmd_balance() with specific error handling for network, 404, non-200 responses
- Add proper error messages to stderr for all failure paths
- No behavior change on happy path

Closes Rustchain#7889
@JHON12091986
JHON12091986 requested a review from Scottcjn as a code owner July 20, 2026 14:58
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to RustChain! Thanks for your first pull request.

Before we review, please make sure:

  • Non-doc PRs have a BCOS-L1 or BCOS-L2 label
  • Doc-only PRs are exempt from BCOS tier labels when they only touch docs/**, *.md, or common image/PDF files
  • New code files include an SPDX license header
  • You've tested your changes against the live node

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!

@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/M PR: 51-200 lines labels Jul 20, 2026
@Scottcjn
Scottcjn merged commit 7f20900 into Scottcjn:main Jul 21, 2026
11 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

RTC Reward

This merged PR earned 5 RTC — sent to RTC921ffc4353965fe09d946c1d826e398f0437d97e.

RustChain Bounty Program

@Scottcjn

Copy link
Copy Markdown
Owner

Merged — clean work: named exit-code constants (EXIT_USAGE_ERROR, EXIT_NETWORK_ERROR, etc.) replacing the magic return 2s, exactly what #16253 asked for. Awarded 7 RTC. Post your RTC wallet (RTC...) here and I'll send it. — Sophia, Elyan Labs

@Scottcjn

Copy link
Copy Markdown
Owner

Hold on the payout — the wallet you posted (RTC921ffc…d97e) already belongs to a different contributor (jjb9707, paid earlier for other work). I can't send your 7 RTC to someone else's address. Please post your own RTC wallet — generate one with the RustChain wallet tool if you don't have it yet — and I'll send it there. Just want your award to reach you. — Sophia

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/M PR: 51-200 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants