git.frostfs.info/TrueCloudLab/frostfs-sdk-go@v0.0.0-20241022124111-5361f0ecebd3/client/status/container.go (about) 1 package apistatus 2 3 import ( 4 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/container" 5 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/status" 6 ) 7 8 // ContainerNotFound describes status of the failure because of the missing container. 9 // Instances provide Status and StatusV2 interfaces. 10 type ContainerNotFound struct { 11 v2 status.Status 12 } 13 14 const defaultContainerNotFoundMsg = "container not found" 15 16 func (x *ContainerNotFound) Error() string { 17 msg := x.v2.Message() 18 if msg == "" { 19 msg = defaultContainerNotFoundMsg 20 } 21 22 return errMessageStatusV2( 23 globalizeCodeV2(container.StatusNotFound, container.GlobalizeFail), 24 msg, 25 ) 26 } 27 28 // implements local interface defined in FromStatusV2 func. 29 func (x *ContainerNotFound) fromStatusV2(st *status.Status) { 30 x.v2 = *st 31 } 32 33 // ToStatusV2 implements StatusV2 interface method. 34 // If the value was returned by FromStatusV2, returns the source message. 35 // Otherwise, returns message with 36 // - code: CONTAINER_NOT_FOUND; 37 // - string message: "container not found"; 38 // - details: empty. 39 func (x ContainerNotFound) ToStatusV2() *status.Status { 40 x.v2.SetCode(globalizeCodeV2(container.StatusNotFound, container.GlobalizeFail)) 41 x.v2.SetMessage(defaultContainerNotFoundMsg) 42 return &x.v2 43 } 44 45 // EACLNotFound describes status of the failure because of the missing eACL 46 // table. 47 // Instances provide Status and StatusV2 interfaces. 48 type EACLNotFound struct { 49 v2 status.Status 50 } 51 52 const defaultEACLNotFoundMsg = "eACL not found" 53 54 func (x *EACLNotFound) Error() string { 55 msg := x.v2.Message() 56 if msg == "" { 57 msg = defaultEACLNotFoundMsg 58 } 59 60 return errMessageStatusV2( 61 globalizeCodeV2(container.StatusEACLNotFound, container.GlobalizeFail), 62 msg, 63 ) 64 } 65 66 // implements local interface defined in FromStatusV2 func. 67 func (x *EACLNotFound) fromStatusV2(st *status.Status) { 68 x.v2 = *st 69 } 70 71 // ToStatusV2 implements StatusV2 interface method. 72 // If the value was returned by FromStatusV2, returns the source message. 73 // Otherwise, returns message with 74 // - code: EACL_NOT_FOUND; 75 // - string message: "eACL not found"; 76 // - details: empty. 77 func (x EACLNotFound) ToStatusV2() *status.Status { 78 x.v2.SetCode(globalizeCodeV2(container.StatusEACLNotFound, container.GlobalizeFail)) 79 x.v2.SetMessage(defaultEACLNotFoundMsg) 80 return &x.v2 81 }