feat(client/v2): improve error message on enums (#21936)
This commit is contained in:
parent
2d8ca73afa
commit
dc2cea5bcf
@ -43,6 +43,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
* [#18626](https://github.com/cosmos/cosmos-sdk/pull/18626) Support for off-chain signing and verification of a file.
|
||||
* [#18461](https://github.com/cosmos/cosmos-sdk/pull/18461) Support governance proposals.
|
||||
|
||||
### Improvements
|
||||
|
||||
* [#21936](https://github.com/cosmos/cosmos-sdk/pull/21936) Print possible enum values in error message after an invalid input was provided.
|
||||
|
||||
### API Breaking Changes
|
||||
|
||||
* [#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)).
|
||||
|
||||
@ -58,7 +58,12 @@ func (e enumValue) String() string {
|
||||
func (e *enumValue) Set(s string) error {
|
||||
valDesc, ok := e.valMap[s]
|
||||
if !ok {
|
||||
return fmt.Errorf("%s is not a valid value for enum %s", s, e.enum.FullName())
|
||||
var validValues []string
|
||||
for k := range e.valMap {
|
||||
validValues = append(validValues, k)
|
||||
}
|
||||
|
||||
return fmt.Errorf("%s is not a valid value for enum %s. Valid values are: %s", s, e.enum.FullName(), strings.Join(validValues, ", "))
|
||||
}
|
||||
e.value = valDesc.Number()
|
||||
return nil
|
||||
|
||||
Loading…
Reference in New Issue
Block a user