return an error when the API file isn't found

fixes #7


This commit was moved from ipfs/go-ipfs-http-client@897d1b1bcd
This commit is contained in:
Steven Allen 2019-03-26 17:02:04 +00:00
parent e76ecd3038
commit c6f704b453

View File

@ -1,6 +1,7 @@
package httpapi
import (
"errors"
"fmt"
"io/ioutil"
gohttp "net/http"
@ -22,6 +23,9 @@ const (
EnvDir = "IPFS_PATH"
)
// ErrApiNotFound if we fail to find a running daemon.
var ErrApiNotFound = errors.New("ipfs api address could not be found")
// HttpApi implements github.com/ipfs/interface-go-ipfs-core/CoreAPI using
// IPFS HTTP API.
//
@ -54,7 +58,7 @@ func NewPathApi(ipfspath string) (*HttpApi, error) {
a, err := ApiAddr(ipfspath)
if err != nil {
if os.IsNotExist(err) {
err = nil
err = ErrApiNotFound
}
return nil, err
}