Skip to content

Commit f179f44

Browse files
facundomedicamergify[bot]
authored andcommitted
feat(client/v2): improve error message on enums (#21936)
(cherry picked from commit dc2cea5) # Conflicts: # client/v2/CHANGELOG.md
1 parent 412f4e7 commit f179f44

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

client/v2/CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,22 @@ Ref: https://keepachangelog.com/en/1.0.0/
3838

3939
### Bug Fixes
4040

41+
<<<<<<< HEAD
4142
* [#21809](https://github.com/cosmos/cosmos-sdk/pull/21809) Correctly handle enhanced sub commands.
43+
=======
44+
### Features
45+
46+
* [#18626](https://github.com/cosmos/cosmos-sdk/pull/18626) Support for off-chain signing and verification of a file.
47+
* [#18461](https://github.com/cosmos/cosmos-sdk/pull/18461) Support governance proposals.
48+
49+
### Improvements
50+
51+
* [#21936](https://github.com/cosmos/cosmos-sdk/pull/21936) Print possible enum values in error message after an invalid input was provided.
52+
53+
### API Breaking Changes
54+
55+
* [#17709](https://github.com/cosmos/cosmos-sdk/pull/17709) Address codecs have been removed from `autocli.AppOptions` and `flag.Builder`. Instead client/v2 uses the address codecs present in the context (introduced in [#17503](https://github.com/cosmos/cosmos-sdk/pull/17503)).
56+
>>>>>>> dc2cea5bc (feat(client/v2): improve error message on enums (#21936))
4257
4358
## [v2.0.0-beta.5] - 2024-09-18
4459

client/v2/autocli/flag/enum.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ func (e enumValue) String() string {
5858
func (e *enumValue) Set(s string) error {
5959
valDesc, ok := e.valMap[s]
6060
if !ok {
61-
return fmt.Errorf("%s is not a valid value for enum %s", s, e.enum.FullName())
61+
var validValues []string
62+
for k := range e.valMap {
63+
validValues = append(validValues, k)
64+
}
65+
66+
return fmt.Errorf("%s is not a valid value for enum %s. Valid values are: %s", s, e.enum.FullName(), strings.Join(validValues, ", "))
6267
}
6368
e.value = valDesc.Number()
6469
return nil

0 commit comments

Comments
 (0)