mirror of
https://github.com/minio/mc.git
synced 2025-11-16 11:02:34 +03:00
Print proper errors message received on the wire from any Object Storage
This commit is contained in:
13
cmd-mb.go
13
cmd-mb.go
@@ -43,16 +43,20 @@ func doMakeBucketCmd(ctx *cli.Context) {
|
|||||||
bucket, _, err := url2Object(u)
|
bucket, _, err := url2Object(u)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug.Println(iodine.New(err, nil))
|
log.Debug.Println(iodine.New(err, nil))
|
||||||
console.Fatalf("mc: Unable to decode bucket and object from URL[%s]\n", u)
|
console.Fatalf("mc: Unable to decode bucket and object from URL [%s]\n", u)
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is handled differently since http based URLs cannot have
|
// this is handled differently since http based URLs cannot have
|
||||||
// nested directories as buckets, buckets are a unique alphanumeric
|
// nested directories as buckets, buckets are a unique alphanumeric
|
||||||
// name having subdirectories is only supported for fsClient
|
// name having subdirectories is only supported for fsClient
|
||||||
if getURLType(u) != urlFS {
|
if getURLType(u) != urlFS {
|
||||||
|
if bucket == "" {
|
||||||
|
log.Debug.Println(iodine.New(errBucketNameEmpty{}, nil))
|
||||||
|
console.Fatalln("mc: bucket name empty")
|
||||||
|
}
|
||||||
if !client.IsValidBucketName(bucket) {
|
if !client.IsValidBucketName(bucket) {
|
||||||
log.Debug.Println(iodine.New(err, nil))
|
log.Debug.Println(iodine.New(errInvalidBucketName{bucket: bucket}, nil))
|
||||||
console.Fatalf("mc: Invalid bucket name: %s", bucket)
|
console.Fatalf("mc: Invalid bucket name: [%s]\n", bucket)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,14 +70,13 @@ func doMakeBucketCmd(ctx *cli.Context) {
|
|||||||
// retry - 5 times
|
// retry - 5 times
|
||||||
for r := retries.init(); r.retry(); {
|
for r := retries.init(); r.retry(); {
|
||||||
err = clnt.PutBucket(bucket)
|
err = clnt.PutBucket(bucket)
|
||||||
|
|
||||||
if !isValidRetry(err) {
|
if !isValidRetry(err) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug.Println(iodine.New(err, nil))
|
log.Debug.Println(iodine.New(err, nil))
|
||||||
// error message returned properly by PutBucket()
|
console.Infoln()
|
||||||
console.Fatalln(err)
|
console.Fatalln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
errors.go
19
errors.go
@@ -90,12 +90,27 @@ type errAliasNotFound struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e errAliasNotFound) Error() string {
|
func (e errAliasNotFound) Error() string {
|
||||||
return fmt.Sprintf("alias: %s exists", e.name)
|
return "alias: " + e.name + " exists"
|
||||||
}
|
}
|
||||||
|
|
||||||
// errInvalidAuthKeys - invalid authorization keys
|
// errInvalidAuthKeys - invalid authorization keys
|
||||||
type errInvalidAuthKeys struct{}
|
type errInvalidAuthKeys struct{}
|
||||||
|
|
||||||
func (e errInvalidAuthKeys) Error() string {
|
func (e errInvalidAuthKeys) Error() string {
|
||||||
return fmt.Sprintf("invalid authorization keys")
|
return "invalid authorization keys"
|
||||||
|
}
|
||||||
|
|
||||||
|
// errInvalidBucketName - invalid bucket name
|
||||||
|
type errInvalidBucketName struct {
|
||||||
|
bucket string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e errInvalidBucketName) Error() string {
|
||||||
|
return "invalid bucket name: " + e.bucket
|
||||||
|
}
|
||||||
|
|
||||||
|
type errBucketNameEmpty struct{}
|
||||||
|
|
||||||
|
func (e errBucketNameEmpty) Error() string {
|
||||||
|
return "bucket name empty"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,5 +56,6 @@ func NewError(res *http.Response) error {
|
|||||||
|
|
||||||
// Error formats HTTP error string
|
// Error formats HTTP error string
|
||||||
func (e *Error) Error() string {
|
func (e *Error) Error() string {
|
||||||
return fmt.Sprintf("%s", e.response.Status)
|
message, _ := e.responseMap.ValuesForKey("Message")
|
||||||
|
return fmt.Sprintf("[%s] server replied with Message: %s", e.response.Header.Get("Server"), message)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user