@cryptotaxi247 / kubo / commits / 5a9de188d

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

fix(commands/request) return err when unable to load config/node due to nil function cc @jbenet @mappum License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>

Brian Tiger Chow committed Nov 12, 2014 at 23:31 UTC 5a9de188d75163a6544de40ab9b75c63adbb2b6a
1 file changed +3 -2
commands/request.go
+3 -2
@@ -1,6 +1,7 @@
1 package commands
2
3 import (
4 + "errors"
5 "fmt"
6 "io"
7 "reflect"
@@ -29,7 +30,7 @@ func (c *Context) GetConfig() (*config.Config, error) {
30 var err error
31 if c.config == nil {
32 if c.LoadConfig == nil {
32 - panic("nil LoadConfig function")
33 + return nil, errors.New("nil LoadConfig function")
34 }
35 c.config, err = c.LoadConfig(c.ConfigRoot)
36 }
@@ -42,7 +43,7 @@ func (c *Context) GetNode() (*core.IpfsNode, error) {
43 var err error
44 if c.node == nil {
45 if c.ConstructNode == nil {
45 - panic("nil ConstructNode function")
46 + return nil, errors.New("nil ConstructNode function")
47 }
48 c.node, err = c.ConstructNode()
49 }