Add API retry functionality in mc admin (#7602)

This commit is contained in:
Harshavardhana
2019-05-09 17:41:54 -07:00
committed by GitHub
parent 72929ec05b
commit ac3b59645e
3 changed files with 259 additions and 31 deletions

View File

@@ -77,6 +77,28 @@ func httpRespToErrorResponse(resp *http.Response) error {
return errResp
}
// ToErrorResponse - Returns parsed ErrorResponse struct from body and
// http headers.
//
// For example:
//
// import admin "github.com/minio/minio/pkg/madmin"
// ...
// ...
// ss, err := adm.ServiceStatus(...)
// if err != nil {
// resp := admin.ToErrorResponse(err)
// }
// ...
func ToErrorResponse(err error) ErrorResponse {
switch err := err.(type) {
case ErrorResponse:
return err
default:
return ErrorResponse{}
}
}
// ErrInvalidArgument - Invalid argument response.
func ErrInvalidArgument(message string) error {
return ErrorResponse{