Make sure in API we handle all error type exclusively, and return certain values exclusively

This commit is contained in:
Harshavardhana
2015-03-31 20:26:14 -07:00
parent 0491e1bbf1
commit a56098b8c9
3 changed files with 39 additions and 3 deletions

View File

@@ -84,6 +84,11 @@ func (server *minioAPI) getObjectHandler(w http.ResponseWriter, req *http.Reques
{
writeErrorResponse(w, req, InvalidBucketName, acceptsContentType, req.URL.Path)
}
case drivers.ImplementationError:
{
log.Error.Println(err)
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path)
}
default:
{
log.Error.Println(err)
@@ -105,8 +110,10 @@ func (server *minioAPI) headObjectHandler(w http.ResponseWriter, req *http.Reque
metadata, err := server.driver.GetObjectMetadata(bucket, object, "")
switch err := err.(type) {
case nil:
setObjectHeaders(w, metadata)
w.WriteHeader(http.StatusOK)
{
setObjectHeaders(w, metadata)
w.WriteHeader(http.StatusOK)
}
case drivers.ObjectNotFound:
{
writeErrorResponse(w, req, NoSuchKey, acceptsContentType, req.URL.Path)
@@ -120,6 +127,11 @@ func (server *minioAPI) headObjectHandler(w http.ResponseWriter, req *http.Reque
log.Error.Println(err)
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path)
}
default:
{
log.Error.Println(err)
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path)
}
}
}
@@ -174,5 +186,10 @@ func (server *minioAPI) putObjectHandler(w http.ResponseWriter, req *http.Reques
{
writeErrorResponse(w, req, InvalidDigest, acceptsContentType, req.URL.Path)
}
default:
{
log.Error.Println(err)
writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path)
}
}
}