From 3e9bc4bce73cf4db243ab864e05c670cb6a21298 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Thu, 24 Aug 2023 19:54:10 +0300 Subject: [PATCH] cli: Add separate code for `ObjectAlreadyRemoved` Refs #2376. Signed-off-by: Pavel Karpy --- CHANGELOG.md | 1 + cmd/neofs-cli/internal/common/exit.go | 6 +++++- docs/cli-exit-codes.md | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1272264e633..06ea8a31054 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ minor release, the component will be purged, so be prepared (see `Updating` sect - SN's version and capacity is announced via the attributes automatically but can be overwritten explicitly (#2455, #602) - `peapod` command for `neofs-lens` (#2507) - New CLI exit code for awaiting timeout (#2380) +- New CLI exit code for already removed objects (#2376) ### Fixed - `neo-go` RPC connection loss handling (#1337) diff --git a/cmd/neofs-cli/internal/common/exit.go b/cmd/neofs-cli/internal/common/exit.go index be16f6e2131..27d9203433e 100644 --- a/cmd/neofs-cli/internal/common/exit.go +++ b/cmd/neofs-cli/internal/common/exit.go @@ -33,10 +33,12 @@ func ExitOnErr(cmd *cobra.Command, errFmt string, err error) { internal aclDenied awaitTimeout + alreadyRemoved ) var code int var accessErr = new(sdkstatus.ObjectAccessDenied) + var alreadyRemovedErr = new(sdkstatus.ObjectAlreadyRemoved) switch { case errors.Is(err, sdkstatus.ErrServerInternal): @@ -46,8 +48,10 @@ func ExitOnErr(cmd *cobra.Command, errFmt string, err error) { err = fmt.Errorf("%w: %s", err, accessErr.Reason()) case errors.Is(err, ErrAwaitTimeout): code = awaitTimeout + case errors.As(err, alreadyRemovedErr): + code = awaitTimeout default: - code = internal + code = alreadyRemoved } cmd.PrintErrln(err) diff --git a/docs/cli-exit-codes.md b/docs/cli-exit-codes.md index 89ec5f05282..dd76f39b805 100644 --- a/docs/cli-exit-codes.md +++ b/docs/cli-exit-codes.md @@ -11,6 +11,7 @@ The NeoFS CLI returns specific exit codes to indicate the outcome of command exe | 1 | Internal error or an unspecified failure. | | 2 | Object access denied or unauthorized. | | 3 | Await timeout expired for a certain condition. | +| 4 | Object already removed. |