mirror of
https://github.com/minio/minio.git
synced 2025-01-23 12:43:16 -05:00
Adding comments to errors
This commit is contained in:
parent
53f116616f
commit
c3cda5d9a8
@ -42,10 +42,13 @@ func (server *minioAPI) getObjectHandler(w http.ResponseWriter, req *http.Reques
|
|||||||
httpRange, err := getRequestedRange(req, metadata.Size)
|
httpRange, err := getRequestedRange(req, metadata.Size)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error.Println(err)
|
log.Error.Println(err)
|
||||||
|
// get error
|
||||||
error := getErrorCode(InvalidRange)
|
error := getErrorCode(InvalidRange)
|
||||||
errorResponse := getErrorResponse(error, "/"+bucket+"/"+object)
|
errorResponse := getErrorResponse(error, "/"+bucket+"/"+object)
|
||||||
|
// set headers
|
||||||
setCommonHeaders(w, getContentTypeString(acceptsContentType))
|
setCommonHeaders(w, getContentTypeString(acceptsContentType))
|
||||||
w.WriteHeader(error.HTTPStatusCode)
|
w.WriteHeader(error.HTTPStatusCode)
|
||||||
|
// write body
|
||||||
encodedErrorResponse := encodeErrorResponse(errorResponse, acceptsContentType)
|
encodedErrorResponse := encodeErrorResponse(errorResponse, acceptsContentType)
|
||||||
w.Write(encodedErrorResponse)
|
w.Write(encodedErrorResponse)
|
||||||
return
|
return
|
||||||
@ -73,46 +76,61 @@ func (server *minioAPI) getObjectHandler(w http.ResponseWriter, req *http.Reques
|
|||||||
}
|
}
|
||||||
case drivers.ObjectNotFound:
|
case drivers.ObjectNotFound:
|
||||||
{
|
{
|
||||||
|
// get error
|
||||||
error := getErrorCode(NoSuchKey)
|
error := getErrorCode(NoSuchKey)
|
||||||
errorResponse := getErrorResponse(error, "/"+bucket+"/"+object)
|
errorResponse := getErrorResponse(error, "/"+bucket+"/"+object)
|
||||||
|
// set headers
|
||||||
setCommonHeaders(w, getContentTypeString(acceptsContentType))
|
setCommonHeaders(w, getContentTypeString(acceptsContentType))
|
||||||
w.WriteHeader(error.HTTPStatusCode)
|
w.WriteHeader(error.HTTPStatusCode)
|
||||||
|
// write body
|
||||||
encodedErrorResponse := encodeErrorResponse(errorResponse, acceptsContentType)
|
encodedErrorResponse := encodeErrorResponse(errorResponse, acceptsContentType)
|
||||||
w.Write(encodedErrorResponse)
|
w.Write(encodedErrorResponse)
|
||||||
}
|
}
|
||||||
case drivers.BucketNotFound:
|
case drivers.BucketNotFound:
|
||||||
{
|
{
|
||||||
|
// get error
|
||||||
error := getErrorCode(NoSuchBucket)
|
error := getErrorCode(NoSuchBucket)
|
||||||
errorResponse := getErrorResponse(error, "/"+bucket+"/"+object)
|
errorResponse := getErrorResponse(error, "/"+bucket+"/"+object)
|
||||||
|
// set headers
|
||||||
setCommonHeaders(w, getContentTypeString(acceptsContentType))
|
setCommonHeaders(w, getContentTypeString(acceptsContentType))
|
||||||
w.WriteHeader(error.HTTPStatusCode)
|
w.WriteHeader(error.HTTPStatusCode)
|
||||||
|
// write body
|
||||||
encodedErrorResponse := encodeErrorResponse(errorResponse, acceptsContentType)
|
encodedErrorResponse := encodeErrorResponse(errorResponse, acceptsContentType)
|
||||||
w.Write(encodedErrorResponse)
|
w.Write(encodedErrorResponse)
|
||||||
}
|
}
|
||||||
case drivers.ObjectNameInvalid:
|
case drivers.ObjectNameInvalid:
|
||||||
{
|
{
|
||||||
|
// get error
|
||||||
error := getErrorCode(NoSuchKey)
|
error := getErrorCode(NoSuchKey)
|
||||||
errorResponse := getErrorResponse(error, "/"+bucket+"/"+object)
|
errorResponse := getErrorResponse(error, "/"+bucket+"/"+object)
|
||||||
|
// set headers
|
||||||
setCommonHeaders(w, getContentTypeString(acceptsContentType))
|
setCommonHeaders(w, getContentTypeString(acceptsContentType))
|
||||||
w.WriteHeader(error.HTTPStatusCode)
|
w.WriteHeader(error.HTTPStatusCode)
|
||||||
|
// write body
|
||||||
encodedErrorResponse := encodeErrorResponse(errorResponse, acceptsContentType)
|
encodedErrorResponse := encodeErrorResponse(errorResponse, acceptsContentType)
|
||||||
w.Write(encodedErrorResponse)
|
w.Write(encodedErrorResponse)
|
||||||
}
|
}
|
||||||
case drivers.BucketNameInvalid:
|
case drivers.BucketNameInvalid:
|
||||||
{
|
{
|
||||||
|
// get error
|
||||||
error := getErrorCode(InvalidBucketName)
|
error := getErrorCode(InvalidBucketName)
|
||||||
errorResponse := getErrorResponse(error, "/"+bucket+"/"+object)
|
errorResponse := getErrorResponse(error, "/"+bucket+"/"+object)
|
||||||
|
// set headers
|
||||||
setCommonHeaders(w, getContentTypeString(acceptsContentType))
|
setCommonHeaders(w, getContentTypeString(acceptsContentType))
|
||||||
w.WriteHeader(error.HTTPStatusCode)
|
w.WriteHeader(error.HTTPStatusCode)
|
||||||
|
// wrkite body
|
||||||
encodedErrorResponse := encodeErrorResponse(errorResponse, acceptsContentType)
|
encodedErrorResponse := encodeErrorResponse(errorResponse, acceptsContentType)
|
||||||
w.Write(encodedErrorResponse)
|
w.Write(encodedErrorResponse)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
// get error
|
||||||
// Embed errors log on serve side
|
// Embed errors log on serve side
|
||||||
log.Error.Println(err)
|
log.Error.Println(err)
|
||||||
|
// set headers
|
||||||
error := getErrorCode(InternalError)
|
error := getErrorCode(InternalError)
|
||||||
errorResponse := getErrorResponse(error, "/"+bucket+"/"+object)
|
errorResponse := getErrorResponse(error, "/"+bucket+"/"+object)
|
||||||
|
// write body
|
||||||
setCommonHeaders(w, getContentTypeString(acceptsContentType))
|
setCommonHeaders(w, getContentTypeString(acceptsContentType))
|
||||||
w.WriteHeader(error.HTTPStatusCode)
|
w.WriteHeader(error.HTTPStatusCode)
|
||||||
encodedErrorResponse := encodeErrorResponse(errorResponse, acceptsContentType)
|
encodedErrorResponse := encodeErrorResponse(errorResponse, acceptsContentType)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user