More meaningful error messages with unsupported filesystem operations (share and policy) (#1833)

This commit is contained in:
Anis Elleuch
2016-09-25 10:20:56 -07:00
committed by Harshavardhana
parent 2b24a7b520
commit 15b91126d5
4 changed files with 43 additions and 7 deletions
+1 -1
View File
@@ -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
+26 -4
View File
@@ -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",
+8 -1
View File
@@ -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+"’.")
}
}
}
}
+8 -1
View File
@@ -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+"’.")
}
}
}
}