MCPcopy Create free account
hub / github.com/AbelChe/evil_minio / toObjectErr

Function toObjectErr

cmd/object-api-errors.go:30–176  ·  view source on GitHub ↗

Converts underlying storage error. Convenience function written to handle all cases where we have known types of errors returned by underlying storage layer.

(err error, params ...string)

Source from the content-addressed store, hash-verified

28// handle all cases where we have known types of errors returned by
29// underlying storage layer.
30func toObjectErr(err error, params ...string) error {
31 if err == nil {
32 return nil
33 }
34 if errors.Is(err, context.Canceled) {
35 return context.Canceled
36 }
37 switch err.Error() {
38 case errVolumeNotFound.Error():
39 apiErr := BucketNotFound{}
40 if len(params) >= 1 {
41 apiErr.Bucket = params[0]
42 }
43 return apiErr
44 case errVolumeNotEmpty.Error():
45 apiErr := BucketNotEmpty{}
46 if len(params) >= 1 {
47 apiErr.Bucket = params[0]
48 }
49 return apiErr
50 case errVolumeExists.Error():
51 apiErr := BucketExists{}
52 if len(params) >= 1 {
53 apiErr.Bucket = params[0]
54 }
55 return apiErr
56 case errDiskFull.Error():
57 return StorageFull{}
58 case errTooManyOpenFiles.Error():
59 return SlowDown{}
60 case errFileAccessDenied.Error():
61 apiErr := PrefixAccessDenied{}
62 if len(params) >= 1 {
63 apiErr.Bucket = params[0]
64 }
65 if len(params) >= 2 {
66 apiErr.Object = decodeDirObject(params[1])
67 }
68 return apiErr
69 case errIsNotRegular.Error():
70 apiErr := ObjectExistsAsDirectory{}
71 if len(params) >= 1 {
72 apiErr.Bucket = params[0]
73 }
74 if len(params) >= 2 {
75 apiErr.Object = decodeDirObject(params[1])
76 }
77 return apiErr
78 case errFileVersionNotFound.Error():
79 apiErr := VersionNotFound{}
80 if len(params) >= 1 {
81 apiErr.Bucket = params[0]
82 }
83 if len(params) >= 2 {
84 apiErr.Object = decodeDirObject(params[1])
85 }
86 if len(params) >= 3 {
87 apiErr.VersionID = params[2]

Callers 15

getPoolIdxNoLockMethod · 0.85
getPoolIdxMethod · 0.85
MakeBucketMethod · 0.85
GetObjectNInfoMethod · 0.85
PutObjectMethod · 0.85
NewMultipartUploadMethod · 0.85
GetBucketInfoMethod · 0.85
DeleteBucketMethod · 0.85
HealBucketMethod · 0.85
isRemoteCallRequiredFunction · 0.85
CopyObjectPartMethod · 0.85

Calls 3

decodeDirObjectFunction · 0.85
IsMethod · 0.80
ErrorMethod · 0.65

Tested by 7

TestGetObjectNoQuorumFunction · 0.68
TestHeadObjectNoQuorumFunction · 0.68
TestPutObjectNoQuorumFunction · 0.68
TestToErrIsNilFunction · 0.68