mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
add error details
This commit is contained in:
parent
4e3ea49cff
commit
78aabf66ce
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (fs *FilerServer) registerHandler(w http.ResponseWriter, r *http.Request) {
|
func (fs *FilerServer) registerHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -16,19 +17,19 @@ func (fs *FilerServer) registerHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
fileSize, err := strconv.ParseUint(r.FormValue("fileSize"), 10, 64)
|
fileSize, err := strconv.ParseUint(r.FormValue("fileSize"), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(0).Infof("register %s to %s parse fileSize %s: %v", fileId, path, r.FormValue("fileSize"), err)
|
glog.V(0).Infof("register %s to %s parse fileSize %s: %v", fileId, path, r.FormValue("fileSize"), err)
|
||||||
writeJsonError(w, r, http.StatusInternalServerError, err)
|
writeJsonError(w, r, http.StatusInternalServerError, fmt.Errorf("parsing fileSize: %v", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
uid, err := strconv.ParseUint(r.FormValue("uid"), 10, 64)
|
uid, err := strconv.ParseUint(r.FormValue("uid"), 10, 64)
|
||||||
if err != nil && r.FormValue("uid") != "" {
|
if err != nil && r.FormValue("uid") != "" {
|
||||||
glog.V(0).Infof("register %s to %s parse uid %s: %v", fileId, path, r.FormValue("uid"), err)
|
glog.V(0).Infof("register %s to %s parse uid %s: %v", fileId, path, r.FormValue("uid"), err)
|
||||||
writeJsonError(w, r, http.StatusInternalServerError, err)
|
writeJsonError(w, r, http.StatusInternalServerError, fmt.Errorf("parsing uid: %v", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
gid, err := strconv.ParseUint(r.FormValue("gid"), 10, 64)
|
gid, err := strconv.ParseUint(r.FormValue("gid"), 10, 64)
|
||||||
if err != nil && r.FormValue("gid") != "" {
|
if err != nil && r.FormValue("gid") != "" {
|
||||||
glog.V(0).Infof("register %s to %s parse gid %s: %v", fileId, path, r.FormValue("gid"), err)
|
glog.V(0).Infof("register %s to %s parse gid %s: %v", fileId, path, r.FormValue("gid"), err)
|
||||||
writeJsonError(w, r, http.StatusInternalServerError, err)
|
writeJsonError(w, r, http.StatusInternalServerError, fmt.Errorf("parsing gid: %v", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
entry := &filer2.Entry{
|
entry := &filer2.Entry{
|
||||||
|
@ -50,7 +51,7 @@ func (fs *FilerServer) registerHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
err = fs.filer.CreateEntry(entry)
|
err = fs.filer.CreateEntry(entry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(0).Infof("register %s to %s error: %v", fileId, path, err)
|
glog.V(0).Infof("register %s to %s error: %v", fileId, path, err)
|
||||||
writeJsonError(w, r, http.StatusInternalServerError, err)
|
writeJsonError(w, r, http.StatusInternalServerError, fmt.Errorf("create %s: %v", path, err))
|
||||||
} else {
|
} else {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue