more error messages

This commit is contained in:
Chris Lu 2012-09-20 02:53:23 -07:00
parent 462f2ed958
commit 7d8e9f829c

View file

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