more error handling

This commit is contained in:
Chris Lu
2012-09-26 14:28:46 -07:00
parent a847e2beee
commit 20706d8cf2
4 changed files with 27 additions and 9 deletions

View File

@@ -133,6 +133,7 @@ func PostHandler(w http.ResponseWriter, r *http.Request) {
writeJson(w, r, ne)
} else {
ret := store.Write(volumeId, needle)
errorStatus := ""
if ret > 0 || !store.HasVolume(volumeId) { //send to other replica locations
if r.FormValue("type") != "standard" {
if distributedOperation(volumeId, func(location operation.Location) bool {
@@ -142,16 +143,19 @@ func PostHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusCreated)
} else {
ret = 0
errorStatus = "Failed to write to replicas for volume " + volumeId.String()
w.WriteHeader(http.StatusInternalServerError)
}
} else {
w.WriteHeader(http.StatusCreated)
}
} else {
errorStatus = "Failed to write to local disk"
w.WriteHeader(http.StatusInternalServerError)
}
m := make(map[string]uint32)
m := make(map[string]interface{})
m["size"] = ret
m["error"] = errorStatus
writeJson(w, r, m)
}
}