diff --git a/cmd/client-errors.go b/cmd/client-errors.go index 70321d42..f088328b 100644 --- a/cmd/client-errors.go +++ b/cmd/client-errors.go @@ -27,7 +27,7 @@ type APINotImplemented struct { } func (e APINotImplemented) Error() string { - return "‘" + e.API + "’ feature " + "is not implemented for ‘" + e.APIType + "’." + return "‘" + e.API + "’ is not supported for ‘" + e.APIType + "’." } // GenericBucketError - generic bucket operations error diff --git a/cmd/policy-main.go b/cmd/policy-main.go index dbe0c09e..8422ede7 100644 --- a/cmd/policy-main.go +++ b/cmd/policy-main.go @@ -211,7 +211,12 @@ func mainPolicy(ctx *cli.Context) { targetURL := ctx.Args().Last() policies, err := doGetAccessRules(targetURL) if err != nil { - fatalIf(err, "Cannot list policies.") + switch err.ToGoError().(type) { + case APINotImplemented: + fatalIf(err.Trace(), "Unable to list policies of a non S3 url ‘"+targetURL+"’.") + default: + fatalIf(err.Trace(targetURL), "Unable to list policies of target ‘"+targetURL+"’.") + } } for k, v := range policies { printMsg(policyRules{Resource: k, Allow: v}) @@ -222,8 +227,17 @@ func mainPolicy(ctx *cli.Context) { targetURL := ctx.Args().Last() err := doSetAccess(targetURL, perms) // Upon error exit. - fatalIf(err.Trace(targetURL, string(perms)), - "Unable to set policy ‘"+string(perms)+"’ for ‘"+targetURL+"’.") + if err != nil { + switch err.ToGoError().(type) { + case APINotImplemented: + fatalIf(err.Trace(), "Unable to set policy of a non S3 url ‘"+targetURL+"’.") + default: + fatalIf(err.Trace(targetURL, string(perms)), + "Unable to set policy ‘"+string(perms)+"’ for ‘"+targetURL+"’.") + + } + } + printMsg(policyMessage{ Status: "success", Operation: "set", @@ -233,7 +247,15 @@ func mainPolicy(ctx *cli.Context) { } else { targetURL := ctx.Args().First() perms, err := doGetAccess(targetURL) - fatalIf(err.Trace(targetURL), "Unable to get policy for ‘"+targetURL+"’.") + if err != nil { + switch err.ToGoError().(type) { + case APINotImplemented: + fatalIf(err.Trace(), "Unable to get policy of a non S3 url ‘"+targetURL+"’.") + default: + fatalIf(err.Trace(targetURL), "Unable to get policy for ‘"+targetURL+"’.") + } + } + printMsg(policyMessage{ Status: "success", Operation: "get", diff --git a/cmd/share-download-main.go b/cmd/share-download-main.go index 0fe6fc81..4d7240d1 100644 --- a/cmd/share-download-main.go +++ b/cmd/share-download-main.go @@ -179,6 +179,13 @@ func mainShareDownload(ctx *cli.Context) { for _, targetURL := range ctx.Args() { err := doShareDownloadURL(targetURL, isRecursive, expiry) - fatalIf(err.Trace(targetURL), "Unable to share target ‘"+targetURL+"’.") + if err != nil { + switch err.ToGoError().(type) { + case APINotImplemented: + fatalIf(err.Trace(), "Unable to share a non S3 url ‘"+targetURL+"’.") + default: + fatalIf(err.Trace(targetURL), "Unable to share target ‘"+targetURL+"’.") + } + } } } diff --git a/cmd/share-upload-main.go b/cmd/share-upload-main.go index 5d62123b..1ad8916f 100644 --- a/cmd/share-upload-main.go +++ b/cmd/share-upload-main.go @@ -206,6 +206,13 @@ func mainShareUpload(ctx *cli.Context) { for _, targetURL := range ctx.Args() { err := doShareUploadURL(targetURL, isRecursive, expiry, contentType) - fatalIf(err.Trace(targetURL), "Unable to generate curl command for upload ‘"+targetURL+"’.") + if err != nil { + switch err.ToGoError().(type) { + case APINotImplemented: + fatalIf(err.Trace(), "Unable to share a non S3 url ‘"+targetURL+"’.") + default: + fatalIf(err.Trace(targetURL), "Unable to generate curl command for upload ‘"+targetURL+"’.") + } + } } }