-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
61 lines (50 loc) · 1.76 KB
/
errors.go
File metadata and controls
61 lines (50 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package s3 //nolint:revive // package name matches folder name
import (
"errors"
"fmt"
"github.com/minio/minio-go/v7"
)
var (
// ErrEmptyHost occurs when the host is not specified.
ErrEmptyHost = errors.New("host not specified")
// ErrEmptyAccessKey occurs when the access key is not specified.
ErrEmptyAccessKey = errors.New("access key not specified")
// ErrEmptyAccessSecret occurs when the access secret is not specified.
ErrEmptyAccessSecret = errors.New("access secret not specified")
// ErrEmptyBucketName occurs when the bucket name is not specified.
ErrEmptyBucketName = errors.New("bucket name not specified")
// ErrNotFound indicates that the requested file does not exist.
ErrNotFound = errors.New("file under specified filepath does not exist")
// ErrChecksumMismatch occurs when the checksum of the downloaded file
// does not match the expected checksum.
ErrChecksumMismatch = errors.New("checksum mismatch")
)
// BucketDoesNotExistError occurs when the given bucket does not exist.
type BucketDoesNotExistError struct {
bucketName string
}
// Error implements the error interface.
func (e *BucketDoesNotExistError) Error() string {
return fmt.Sprintf("bucket '%s' does not exist", e.bucketName)
}
// DownloadingFilesFailedError occurs when downloading files from s3 failed.
type DownloadingFilesFailedError struct {
errs []error
}
// Error implements the error interface.
func (e *DownloadingFilesFailedError) Error() string {
return fmt.Sprintf("failed to download files from s3: %v", e.errs)
}
func handleClientError(err error) error {
const notFound = "NoSuchKey"
var minioResponse minio.ErrorResponse
if errors.As(err, &minioResponse) {
switch minioResponse.Code {
case notFound:
return ErrNotFound
default:
return err
}
}
return err
}