mirror of
https://github.com/pgsty/minio.git
synced 2026-07-22 13:40:22 +03:00
return appropriate error status code in the lock handler (#15950)
This commit is contained in:
+11
-1
@@ -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()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user