mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-26 21:07:45 +08:00
cmd2 fixed config panic
The way the current marshallers marshal out output requires a ton of error checking. I wish there was a way to have the library call our marshaller with the right type (rather than an interface). Maybe can do this with Reflect someday.
This commit is contained in:
parent
f738e899c2
commit
c46d4c8953
@ -90,8 +90,17 @@ Set the value of the 'datastore.path' key:
|
||||
return nil, nil // dont output anything
|
||||
}
|
||||
|
||||
v := res.Output().(*ConfigField)
|
||||
buf, err := config.HumanOutput(v.Value)
|
||||
v := res.Output()
|
||||
if v == nil {
|
||||
k := res.Request().Arguments()[0]
|
||||
return nil, fmt.Errorf("config does not contain key: %s", k)
|
||||
}
|
||||
vf, ok := v.(*ConfigField)
|
||||
if !ok {
|
||||
return nil, u.ErrCast()
|
||||
}
|
||||
|
||||
buf, err := config.HumanOutput(vf.Value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user