More meaningful error messages with unsupported filesystem operations (share and policy) (#1833)
This commit is contained in:
committed by
Harshavardhana
parent
2b24a7b520
commit
15b91126d5
@@ -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
@@ -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",
|
||||
|
||||
@@ -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+"’.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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+"’.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user