forked from minio/minio
-
Notifications
You must be signed in to change notification settings - Fork 14
/
gateway-s3x-errors.go
48 lines (44 loc) · 1.87 KB
/
gateway-s3x-errors.go
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
package s3x
import (
"errors"
minio "github.com/RTradeLtd/s3x/cmd"
)
var (
// ErrLedgerBucketExists is an error message returned from the internal
// ledgerStore indicating that a bucket already exists
ErrLedgerBucketExists = errors.New("bucket exists")
// ErrLedgerBucketDoesNotExist is an error message returned from the internal
// ledgerStore indicating that a bucket does not exist
ErrLedgerBucketDoesNotExist = errors.New("bucket does not exist")
// ErrLedgerObjectDoesNotExist is an error message returned from the internal
// ledgerStore indicating that a object does not exist
ErrLedgerObjectDoesNotExist = errors.New("object does not exist")
// ErrLedgerNonEmptyBucket is an error message returned from the internal
// ledgerStore indicating that a bucket is not empty
ErrLedgerNonEmptyBucket = errors.New("bucket is not empty")
// ErrInvalidUploadID is an error message returned when the multipart upload id
// does not exist
ErrInvalidUploadID = errors.New("invalid multipart upload id")
// ErrInvalidPartNumber is an error message returned when the multipart part
// number is out of range (not mappable to a minio error type)
ErrInvalidPartNumber = errors.New("invalid multipart part number")
)
// toMinioErr converts gRPC or ledger errors into compatible minio errors
// or if no error is present return nil
func (x *xObjects) toMinioErr(err error, bucket, object, id string) error {
switch err {
case ErrLedgerBucketDoesNotExist:
err = minio.BucketNotFound{Bucket: bucket}
case ErrLedgerObjectDoesNotExist:
err = minio.ObjectNotFound{Bucket: bucket, Object: object}
case ErrLedgerBucketExists:
err = minio.BucketAlreadyExists{Bucket: bucket}
case ErrInvalidUploadID:
err = minio.InvalidUploadID{Bucket: bucket, Object: object, UploadID: id}
case ErrLedgerNonEmptyBucket:
err = minio.BucketNotEmpty{Bucket: bucket}
case nil:
return nil
}
return err
}