2022-02-28 08:55:25 +00:00
|
|
|
package apistatus
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/container"
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/status"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ContainerNotFound describes status of the failure because of the missing container.
|
|
|
|
// Instances provide Status and StatusV2 interfaces.
|
|
|
|
type ContainerNotFound struct {
|
|
|
|
v2 status.Status
|
|
|
|
}
|
|
|
|
|
2022-12-08 16:34:52 +00:00
|
|
|
const defaultContainerNotFoundMsg = "container not found"
|
|
|
|
|
2022-02-28 08:55:25 +00:00
|
|
|
func (x ContainerNotFound) Error() string {
|
2022-12-08 16:34:52 +00:00
|
|
|
msg := x.v2.Message()
|
|
|
|
if msg == "" {
|
|
|
|
msg = defaultContainerNotFoundMsg
|
|
|
|
}
|
|
|
|
|
2022-02-28 08:55:25 +00:00
|
|
|
return errMessageStatusV2(
|
|
|
|
globalizeCodeV2(container.StatusNotFound, container.GlobalizeFail),
|
2022-12-08 16:34:52 +00:00
|
|
|
msg,
|
2022-02-28 08:55:25 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// implements local interface defined in FromStatusV2 func.
|
|
|
|
func (x *ContainerNotFound) fromStatusV2(st *status.Status) {
|
|
|
|
x.v2 = *st
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToStatusV2 implements StatusV2 interface method.
|
|
|
|
// If the value was returned by FromStatusV2, returns the source message.
|
|
|
|
// Otherwise, returns message with
|
2022-08-24 14:17:40 +00:00
|
|
|
// - code: CONTAINER_NOT_FOUND;
|
|
|
|
// - string message: "container not found";
|
|
|
|
// - details: empty.
|
2022-02-28 08:55:25 +00:00
|
|
|
func (x ContainerNotFound) ToStatusV2() *status.Status {
|
|
|
|
x.v2.SetCode(globalizeCodeV2(container.StatusNotFound, container.GlobalizeFail))
|
2022-12-08 16:34:52 +00:00
|
|
|
x.v2.SetMessage(defaultContainerNotFoundMsg)
|
2022-02-28 08:55:25 +00:00
|
|
|
return &x.v2
|
|
|
|
}
|
2022-08-01 14:17:48 +00:00
|
|
|
|
|
|
|
// EACLNotFound describes status of the failure because of the missing eACL
|
|
|
|
// table.
|
|
|
|
// Instances provide Status and StatusV2 interfaces.
|
|
|
|
type EACLNotFound struct {
|
|
|
|
v2 status.Status
|
|
|
|
}
|
|
|
|
|
2022-12-08 16:34:52 +00:00
|
|
|
const defaultEACLNotFoundMsg = "eACL not found"
|
|
|
|
|
2022-08-01 14:17:48 +00:00
|
|
|
func (x EACLNotFound) Error() string {
|
2022-12-08 16:34:52 +00:00
|
|
|
msg := x.v2.Message()
|
|
|
|
if msg == "" {
|
|
|
|
msg = defaultEACLNotFoundMsg
|
|
|
|
}
|
|
|
|
|
2022-08-01 14:17:48 +00:00
|
|
|
return errMessageStatusV2(
|
|
|
|
globalizeCodeV2(container.StatusEACLNotFound, container.GlobalizeFail),
|
2022-12-08 16:34:52 +00:00
|
|
|
msg,
|
2022-08-01 14:17:48 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// implements local interface defined in FromStatusV2 func.
|
|
|
|
func (x *EACLNotFound) fromStatusV2(st *status.Status) {
|
|
|
|
x.v2 = *st
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToStatusV2 implements StatusV2 interface method.
|
|
|
|
// If the value was returned by FromStatusV2, returns the source message.
|
|
|
|
// Otherwise, returns message with
|
2022-08-24 14:17:40 +00:00
|
|
|
// - code: EACL_NOT_FOUND;
|
|
|
|
// - string message: "eACL not found";
|
|
|
|
// - details: empty.
|
2022-08-01 14:17:48 +00:00
|
|
|
func (x EACLNotFound) ToStatusV2() *status.Status {
|
|
|
|
x.v2.SetCode(globalizeCodeV2(container.StatusEACLNotFound, container.GlobalizeFail))
|
2022-12-08 16:34:52 +00:00
|
|
|
x.v2.SetMessage(defaultEACLNotFoundMsg)
|
2022-08-01 14:17:48 +00:00
|
|
|
return &x.v2
|
|
|
|
}
|