@@ -17,15 +17,15 @@ import (
17
17
"github.com/rclone/rclone/lib/pacer"
18
18
)
19
19
20
- // PermissionError wraps remote fs errors returned by CheckPermissions function
20
+ // OperationError wraps remote fs errors returned by CheckPermissions function
21
21
// and allows to set a custom message returned to user.
22
- type PermissionError struct {
22
+ type OperationError struct {
23
23
cause error
24
24
op string
25
25
statusCode int
26
26
}
27
27
28
- func asPermissionError (op string , l fs.Fs , err error ) PermissionError {
28
+ func asOperationError (op string , l fs.Fs , err error ) OperationError {
29
29
statusCode := 400
30
30
31
31
if l .Name () == "s3" {
@@ -37,23 +37,23 @@ func asPermissionError(op string, l fs.Fs, err error) PermissionError {
37
37
}
38
38
}
39
39
40
- return PermissionError {
40
+ return OperationError {
41
41
cause : err ,
42
42
op : op ,
43
43
statusCode : statusCode ,
44
44
}
45
45
}
46
46
47
- func (e PermissionError ) Error () string {
48
- return "no " + e .op + " permission" + ": " + e .cause .Error ()
47
+ func (e OperationError ) Error () string {
48
+ return "operation " + e .op + ": " + e .cause .Error ()
49
49
}
50
50
51
- func (e PermissionError ) String () string {
51
+ func (e OperationError ) String () string {
52
52
return e .Error ()
53
53
}
54
54
55
55
// StatusCode returns HTTP status code that should be returned for this error.
56
- func (e PermissionError ) StatusCode () int {
56
+ func (e OperationError ) StatusCode () int {
57
57
return e .statusCode
58
58
}
59
59
@@ -94,7 +94,7 @@ func CheckPermissions(ctx context.Context, l fs.Fs) error {
94
94
if errors .Is (err , credentials .ErrNoValidProvidersFoundInChain ) {
95
95
return errors .New ("no providers - attach IAM Role to EC2 instance or put your access keys to s3 section of /etc/scylla-manager-agent/scylla-manager-agent.yaml and restart agent" ) // nolint: lll
96
96
}
97
- return asPermissionError ("put" , l , err )
97
+ return asOperationError ("put" , l , err )
98
98
}
99
99
}
100
100
@@ -107,7 +107,7 @@ func CheckPermissions(ctx context.Context, l fs.Fs) error {
107
107
if err := operations .ListJSON (ctx , l , testDirName , & opts , func (item * operations.ListJSONItem ) error {
108
108
return nil
109
109
}); err != nil {
110
- return asPermissionError ("list" , l , err )
110
+ return asOperationError ("list" , l , err )
111
111
}
112
112
}
113
113
@@ -119,11 +119,11 @@ func CheckPermissions(ctx context.Context, l fs.Fs) error {
119
119
}
120
120
r , err := o .Open (ctx )
121
121
if err != nil {
122
- return asPermissionError ("open" , l , err )
122
+ return asOperationError ("open" , l , err )
123
123
}
124
124
defer r .Close ()
125
125
if _ , err := io .Copy (io .Discard , r ); err != nil {
126
- return asPermissionError ("copy" , l , err )
126
+ return asOperationError ("copy" , l , err )
127
127
}
128
128
}
129
129
@@ -134,7 +134,7 @@ func CheckPermissions(ctx context.Context, l fs.Fs) error {
134
134
return errors .Wrap (err , "init remote temp dir" )
135
135
}
136
136
if err := operations .Delete (ctx , f ); err != nil {
137
- return asPermissionError ("delete" , l , err )
137
+ return asOperationError ("delete" , l , err )
138
138
}
139
139
}
140
140
0 commit comments