Skip to content

Commit 2cac3ba

Browse files
committed
Fix swift error handling
1 parent 63f42db commit 2cac3ba

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

cli/main.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ package main
44
import (
55
"context"
66
"errors"
7-
"github.com/gosuri/uilive"
8-
"github.com/larrabee/s3sync/pipeline"
9-
"github.com/larrabee/s3sync/storage"
10-
"github.com/sirupsen/logrus"
117
"net/http"
128
_ "net/http/pprof"
139
"os"
1410
"os/signal"
1511
"runtime"
1612
"syscall"
13+
14+
"github.com/gosuri/uilive"
15+
"github.com/sirupsen/logrus"
16+
17+
"github.com/larrabee/s3sync/pipeline"
18+
"github.com/larrabee/s3sync/storage"
1719
)
1820

1921
var cli argsParsed

storage/error_handling.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ package storage
33
import (
44
"context"
55
"errors"
6+
"os"
7+
68
"github.com/aws/aws-sdk-go/aws/awserr"
79
"github.com/aws/aws-sdk-go/aws/request"
810
"github.com/aws/aws-sdk-go/service/s3"
9-
"os"
11+
"github.com/gophercloud/gophercloud"
1012
)
1113

1214
func IsErrNotExist(err error) bool {
@@ -20,6 +22,12 @@ func IsErrNotExist(err error) bool {
2022
if errors.Is(err, os.ErrNotExist) {
2123
return true
2224
}
25+
26+
var sErr gophercloud.ErrDefault404
27+
if errors.As(err, &sErr) {
28+
return true
29+
}
30+
2331
return false
2432
}
2533

@@ -34,6 +42,12 @@ func IsErrPermission(err error) bool {
3442
if errors.Is(err, os.ErrPermission) {
3543
return true
3644
}
45+
46+
var sErr gophercloud.ErrDefault403
47+
if errors.As(err, &sErr) {
48+
return true
49+
}
50+
3751
return false
3852
}
3953

0 commit comments

Comments
 (0)