diff --git a/client/status/object.go b/client/status/object.go index 1ecfd23..cf6674a 100644 --- a/client/status/object.go +++ b/client/status/object.go @@ -135,3 +135,33 @@ func (x ObjectNotFound) ToStatusV2() *status.Status { x.v2.SetMessage("object not found") return &x.v2 } + +// ObjectAlreadyRemoved describes status of the failure because object has been +// already removed. Instances provide Status and StatusV2 interfaces. +type ObjectAlreadyRemoved struct { + v2 status.Status +} + +func (x ObjectAlreadyRemoved) Error() string { + return errMessageStatusV2( + globalizeCodeV2(object.StatusAlreadyRemoved, object.GlobalizeFail), + x.v2.Message(), + ) +} + +// implements local interface defined in FromStatusV2 func. +func (x *ObjectAlreadyRemoved) 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 +// * code: OBJECT_ALREADY_REMOVED; +// * string message: "object already removed"; +// * details: empty. +func (x ObjectAlreadyRemoved) ToStatusV2() *status.Status { + x.v2.SetCode(globalizeCodeV2(object.StatusAlreadyRemoved, object.GlobalizeFail)) + x.v2.SetMessage("object already removed") + return &x.v2 +} diff --git a/client/status/v2.go b/client/status/v2.go index ae58193..bf219a8 100644 --- a/client/status/v2.go +++ b/client/status/v2.go @@ -64,6 +64,8 @@ func FromStatusV2(st *status.Status) Status { decoder = new(ObjectAccessDenied) case object.StatusNotFound: decoder = new(ObjectNotFound) + case object.StatusAlreadyRemoved: + decoder = new(ObjectAlreadyRemoved) } } diff --git a/client/status/v2_test.go b/client/status/v2_test.go index 7fe7935..46379ff 100644 --- a/client/status/v2_test.go +++ b/client/status/v2_test.go @@ -87,6 +87,12 @@ func TestToStatusV2(t *testing.T) { }), codeV2: 2049, }, + { + status: (statusConstructor)(func() apistatus.Status { + return new(apistatus.ObjectAlreadyRemoved) + }), + codeV2: 2052, + }, } { var st apistatus.Status @@ -193,6 +199,12 @@ func TestFromStatusV2(t *testing.T) { }), codeV2: 2049, }, + { + status: (statusConstructor)(func() apistatus.Status { + return new(apistatus.ObjectAlreadyRemoved) + }), + codeV2: 2052, + }, } { var st apistatus.Status