mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -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) {
|
||||
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()))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user