package apistatus import ( "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/container" status "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/status/grpc" statusgrpc "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/status/grpc" "github.com/golang/protobuf/proto" ) // ContainerNotFound describes status of the failure because of the missing container. // Instances provide Status and StatusV2 interfaces. type ContainerNotFound struct { status *statusgrpc.Status } func NewContainerNotFound() ContainerNotFound { return ContainerNotFound{ status: new(statusgrpc.Status), } } const defaultContainerNotFoundMsg = "container not found" func (x ContainerNotFound) Error() string { msg := x.status.GetMessage() if msg == "" { msg = defaultContainerNotFoundMsg } return errMessageStatusV2( globalizeCodeV2(container.StatusNotFound, container.GlobalizeFail), msg, ) } // implements local interface defined in FromStatusV2 func. func (x ContainerNotFound) fromStatusV2(st *status.Status) { if x.status == nil { x.status = new(statusgrpc.Status) } proto.Merge(x.status, st) } // ToStatusV2 implements StatusV2 interface method. // If the value was returned by FromStatusV2, returns the source message. // Otherwise, returns message with // - code: CONTAINER_NOT_FOUND; // - string message: "container not found"; // - details: empty. func (x ContainerNotFound) ToStatusV2() *status.Status { x.status.SetCode(uint32(globalizeCodeV2(container.StatusNotFound, container.GlobalizeFail))) x.status.SetMessage(defaultContainerNotFoundMsg) return x.status } // EACLNotFound describes status of the failure because of the missing eACL // table. // Instances provide Status and StatusV2 interfaces. type EACLNotFound struct { status *statusgrpc.Status } func NewEACLNotFound() EACLNotFound { return EACLNotFound{ status: new(statusgrpc.Status), } } const defaultEACLNotFoundMsg = "eACL not found" func (x EACLNotFound) Error() string { msg := x.status.GetMessage() if msg == "" { msg = defaultEACLNotFoundMsg } return errMessageStatusV2( globalizeCodeV2(container.StatusEACLNotFound, container.GlobalizeFail), msg, ) } // implements local interface defined in FromStatusV2 func. func (x EACLNotFound) fromStatusV2(st *statusgrpc.Status) { if x.status == nil { x.status = new(statusgrpc.Status) } proto.Merge(x.status, st) } // ToStatusV2 implements StatusV2 interface method. // If the value was returned by FromStatusV2, returns the source message. // Otherwise, returns message with // - code: EACL_NOT_FOUND; // - string message: "eACL not found"; // - details: empty. func (x EACLNotFound) ToStatusV2() *statusgrpc.Status { x.status.SetCode(uint32(globalizeCodeV2(container.StatusEACLNotFound, container.GlobalizeFail))) x.status.SetMessage(defaultEACLNotFoundMsg) return x.status }