Skip to content

Commit

Permalink
cli: Add separate code for ObjectAlreadyRemoved
Browse files Browse the repository at this point in the history
Refs #2376.

Signed-off-by: Pavel Karpy <[email protected]>
  • Loading branch information
carpawell committed Aug 24, 2023
1 parent f381361 commit 3e9bc4b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion cmd/neofs-cli/internal/common/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docs/cli-exit-codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |



Expand Down

0 comments on commit 3e9bc4b

Please sign in to comment.