提交 5a9de188 作者: Brian Tiger Chow 提交者: Juan Batiz-Benet

fix(commands/request) return err when unable to load config/node due to

nil function

cc @jbenet @mappum

License: MIT
Signed-off-by: 's avatarBrian Tiger Chow <brian@perfmode.com>
上级 131c15e9
package commands package commands
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"reflect" "reflect"
...@@ -29,7 +30,7 @@ func (c *Context) GetConfig() (*config.Config, error) { ...@@ -29,7 +30,7 @@ func (c *Context) GetConfig() (*config.Config, error) {
var err error var err error
if c.config == nil { if c.config == nil {
if c.LoadConfig == nil { if c.LoadConfig == nil {
panic("nil LoadConfig function") return nil, errors.New("nil LoadConfig function")
} }
c.config, err = c.LoadConfig(c.ConfigRoot) c.config, err = c.LoadConfig(c.ConfigRoot)
} }
...@@ -42,7 +43,7 @@ func (c *Context) GetNode() (*core.IpfsNode, error) { ...@@ -42,7 +43,7 @@ func (c *Context) GetNode() (*core.IpfsNode, error) {
var err error var err error
if c.node == nil { if c.node == nil {
if c.ConstructNode == nil { if c.ConstructNode == nil {
panic("nil ConstructNode function") return nil, errors.New("nil ConstructNode function")
} }
c.node, err = c.ConstructNode() c.node, err = c.ConstructNode()
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论