mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
return appropriate error status code in the lock handler (#15950)
This commit is contained in:
parent
8dd3c41b2a
commit
a35ef155fc
@ -43,7 +43,17 @@ type lockRESTServer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *lockRESTServer) writeErrorResponse(w http.ResponseWriter, err error) {
|
func (l *lockRESTServer) writeErrorResponse(w http.ResponseWriter, err error) {
|
||||||
w.WriteHeader(http.StatusForbidden)
|
statusCode := http.StatusForbidden
|
||||||
|
switch err {
|
||||||
|
case errLockNotInitialized:
|
||||||
|
// Return 425 instead of 5xx, otherwise this node will be marked offline
|
||||||
|
statusCode = http.StatusTooEarly
|
||||||
|
case errLockConflict:
|
||||||
|
statusCode = http.StatusConflict
|
||||||
|
case errLockNotFound:
|
||||||
|
statusCode = http.StatusNotFound
|
||||||
|
}
|
||||||
|
w.WriteHeader(statusCode)
|
||||||
w.Write([]byte(err.Error()))
|
w.Write([]byte(err.Error()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user