return an error when the API file isn't found
fixes #7 This commit was moved from ipfs/go-ipfs-http-client@897d1b1bcdbf9f6616991366e66ac55e18a99a9c
Steven Allen committed
Mar 26, 2019 at 17:02 UTC
c6f704b453cd72734ca03793cd370021f4a39db9
1 file changed
+5
-1
client/httpapi/api.go
+5
-1
@@ -1,6 +1,7 @@
1
package httpapi
2
3
import (
4
+ "errors"
5
"fmt"
6
"io/ioutil"
7
gohttp "net/http"
@@ -22,6 +23,9 @@ const (
23
EnvDir = "IPFS_PATH"
24
)
25
26
+// ErrApiNotFound if we fail to find a running daemon.
27
+var ErrApiNotFound = errors.New("ipfs api address could not be found")
28
+
29
// HttpApi implements github.com/ipfs/interface-go-ipfs-core/CoreAPI using
30
// IPFS HTTP API.
31
//
@@ -54,7 +58,7 @@ func NewPathApi(ipfspath string) (*HttpApi, error) {
58
a, err := ApiAddr(ipfspath)
59
if err != nil {
60
if os.IsNotExist(err) {
57
- err = nil
61
+ err = ErrApiNotFound
62
}
63
return nil, err
64
}