fix: remove showing app name twice in errors (#368)
This commit is contained in:
+5
-2
@@ -201,7 +201,7 @@ func (c *Context) Validate() error { // nolint: gocyclo
|
|||||||
|
|
||||||
case *Application:
|
case *Application:
|
||||||
value = node.Target
|
value = node.Target
|
||||||
desc = node.Name
|
desc = ""
|
||||||
|
|
||||||
case *Node:
|
case *Node:
|
||||||
value = node.Target
|
value = node.Target
|
||||||
@@ -209,7 +209,10 @@ func (c *Context) Validate() error { // nolint: gocyclo
|
|||||||
}
|
}
|
||||||
if validate := isValidatable(value); validate != nil {
|
if validate := isValidatable(value); validate != nil {
|
||||||
if err := validate.Validate(); err != nil {
|
if err := validate.Validate(); err != nil {
|
||||||
return fmt.Errorf("%s: %w", desc, err)
|
if desc != "" {
|
||||||
|
return fmt.Errorf("%s: %w", desc, err)
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1214,7 +1214,7 @@ func TestValidateApp(t *testing.T) {
|
|||||||
cli := validateCli{}
|
cli := validateCli{}
|
||||||
p := mustNew(t, &cli)
|
p := mustNew(t, &cli)
|
||||||
_, err := p.Parse([]string{})
|
_, err := p.Parse([]string{})
|
||||||
assert.EqualError(t, err, "test: app error")
|
assert.EqualError(t, err, "app error")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateCmd(t *testing.T) {
|
func TestValidateCmd(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user