Commit 52a86ec
Improve CLI error handling for contract invocation arguments (#2235)
Fixes #2182 - Enhanced error messages with context and suggestions for
better developer experience when invoking contracts, especially with
bash scripts.
Providing detailed, context-rich error messages for contract invocation
arguments, including expected vs. received types and actionable
suggestions.
- Pre-validating JSON arguments to catch malformed input and type
mismatches early.
- Detecting common mistakes, such as invalid addresses and quoting
errors, with documentation links and best practices.
- Refactoring argument parsing internals for better organization,
maintainability, and adherence to Rust best practices:
- Extracts long functions into focused helpers (build_clap_command,
parse_command_matches, get_function_spec, parse_function_arguments,
parse_single_argument, parse_file_argument, build_invoke_contract_args).
- Improves error handling (e.g., replacing map().unwrap_or_else() with
explicit matching).
### Example improvement:
**Before**: Error: parsing argument amount: InvalidValue(Some(U64))
**After**: Failed to parse argument 'amount' - Expected u64 but received
'"100"'
Suggestion: For numbers, ensure no quotes around the value
---------
Co-authored-by: Nando Vieira <me@fnando.com>1 parent 8508cce commit 52a86ec
File tree
2 files changed
+511
-76
lines changed- cmd
- crates/soroban-test/tests/it
- soroban-cli/src/commands/contract
2 files changed
+511
-76
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
0 commit comments