mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-10 10:47:51 +08:00
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:
parent
e76ecd3038
commit
c6f704b453
@ -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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user