more error messages
This commit is contained in:
@@ -5,7 +5,8 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"pkg/storage"
|
"pkg/storage"
|
||||||
"pkg/util"
|
"pkg/util"
|
||||||
"fmt"
|
_ "fmt"
|
||||||
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Location struct {
|
type Location struct {
|
||||||
@@ -17,11 +18,11 @@ type LookupResult struct {
|
|||||||
Error string "error"
|
Error string "error"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Add a caching for vid here
|
||||||
func Lookup(server string, vid storage.VolumeId) (*LookupResult, error) {
|
func Lookup(server string, vid storage.VolumeId) (*LookupResult, error) {
|
||||||
values := make(url.Values)
|
values := make(url.Values)
|
||||||
values.Add("volumeId", vid.String())
|
values.Add("volumeId", vid.String())
|
||||||
jsonBlob, err := util.Post("http://"+server+"/dir/lookup", values)
|
jsonBlob, err := util.Post("http://"+server+"/dir/lookup", values)
|
||||||
fmt.Println("Lookup Result:", string(jsonBlob))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -30,5 +31,8 @@ func Lookup(server string, vid storage.VolumeId) (*LookupResult, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if ret.Error != ""{
|
||||||
|
return nil, errors.New(ret.Error)
|
||||||
|
}
|
||||||
return &ret, nil
|
return &ret, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user