Commit f96d5017 authored by acud's avatar acud Committed by GitHub

api: standardize error codes (#793)

* return 404
parent 3d8c3741
......@@ -68,7 +68,7 @@ func (s *server) bytesGetHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
logger.Debugf("bytes: parse address %s: %v", nameOrHex, err)
logger.Error("bytes: parse address error")
jsonhttp.BadRequest(w, "invalid address")
jsonhttp.NotFound(w, nil)
return
}
......
......@@ -45,7 +45,7 @@ func (s *server) bzzDownloadHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
logger.Debugf("bzz download: parse address %s: %v", nameOrHex, err)
logger.Error("bzz download: parse address")
jsonhttp.BadRequest(w, "invalid address")
jsonhttp.NotFound(w, nil)
return
}
......@@ -67,7 +67,7 @@ func (s *server) bzzDownloadHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
logger.Debugf("bzz download: unmarshal entry %s: %v", address, err)
logger.Errorf("bzz download: unmarshal entry %s", address)
jsonhttp.InternalServerError(w, "error unmarshaling entry")
jsonhttp.NotFound(w, nil)
return
}
......@@ -85,7 +85,7 @@ func (s *server) bzzDownloadHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
logger.Debugf("bzz download: unmarshal metadata %s: %v", address, err)
logger.Errorf("bzz download: unmarshal metadata %s", address)
jsonhttp.InternalServerError(w, "error unmarshaling metadata")
jsonhttp.NotFound(w, nil)
return
}
......@@ -100,7 +100,7 @@ func (s *server) bzzDownloadHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
logger.Debugf("bzz download: not manifest %s: %v", address, err)
logger.Error("bzz download: not manifest")
jsonhttp.BadRequest(w, "not manifest")
jsonhttp.NotFound(w, nil)
return
}
......@@ -176,7 +176,7 @@ func (s *server) bzzDownloadHandler(w http.ResponseWriter, r *http.Request) {
jsonhttp.NotFound(w, "path address not found")
} else {
jsonhttp.BadRequest(w, "invalid path address")
jsonhttp.NotFound(w, nil)
}
return
}
......@@ -203,7 +203,7 @@ func (s *server) serveManifestEntry(w http.ResponseWriter, r *http.Request, j fi
if err != nil {
logger.Debugf("bzz download: unmarshal file entry %s: %v", address, err)
logger.Errorf("bzz download: unmarshal file entry %s", address)
jsonhttp.InternalServerError(w, "error unmarshaling file entry")
jsonhttp.NotFound(w, nil)
return
}
......@@ -221,7 +221,7 @@ func (s *server) serveManifestEntry(w http.ResponseWriter, r *http.Request, j fi
if err != nil {
logger.Debugf("bzz download: unmarshal metadata %s: %v", address, err)
logger.Errorf("bzz download: unmarshal metadata %s", address)
jsonhttp.InternalServerError(w, "error unmarshaling metadata")
jsonhttp.NotFound(w, nil)
return
}
......
......@@ -107,7 +107,7 @@ func (s *server) chunkGetHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
s.Logger.Debugf("chunk: parse chunk address %s: %v", nameOrHex, err)
s.Logger.Error("chunk: parse chunk address error")
jsonhttp.BadRequest(w, "invalid chunk address")
jsonhttp.NotFound(w, nil)
return
}
......
......@@ -237,7 +237,7 @@ func (s *server) fileDownloadHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
logger.Debugf("file download: parse file address %s: %v", nameOrHex, err)
logger.Errorf("file download: parse file address %s", nameOrHex)
jsonhttp.BadRequest(w, "invalid file address")
jsonhttp.NotFound(w, nil)
return
}
......@@ -261,7 +261,7 @@ func (s *server) fileDownloadHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
logger.Debugf("file download: unmarshal entry %s: %v", address, err)
logger.Errorf("file download: unmarshal entry %s", address)
jsonhttp.InternalServerError(w, "error unmarshaling entry")
jsonhttp.NotFound(w, nil)
return
}
......@@ -289,7 +289,7 @@ func (s *server) fileDownloadHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
logger.Debugf("file download: unmarshal metadata %s: %v", nameOrHex, err)
logger.Errorf("file download: unmarshal metadata %s", nameOrHex)
jsonhttp.InternalServerError(w, "error unmarshaling metadata")
jsonhttp.NotFound(w, nil)
return
}
......@@ -315,7 +315,7 @@ func (s *server) downloadHandler(w http.ResponseWriter, r *http.Request, referen
if errors.Is(err, storage.ErrNotFound) {
logger.Debugf("api download: not found %s: %v", reference, err)
logger.Error("api download: not found")
jsonhttp.NotFound(w, "not found")
jsonhttp.NotFound(w, nil)
return
}
logger.Debugf("api download: invalid root chunk %s: %v", reference, err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment