[#1252] neofs-cli: Print details for AccessDenied errors

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-03-21 18:33:17 +03:00 committed by Alex Vanin
parent 2848001dfb
commit 32badab11a

View file

@ -515,17 +515,22 @@ func exitOnErr(cmd *cobra.Command, err error) {
const ( const (
_ = iota _ = iota
internal internal
aclDenied
) )
var ( var (
code int code int
internalErr = new(sdkstatus.ServerInternal) internalErr = new(sdkstatus.ServerInternal)
accessErr = new(sdkstatus.ObjectAccessDenied)
) )
switch { switch {
case errors.As(err, &internalErr): case errors.As(err, &internalErr):
code = internal code = internal
case errors.As(err, &accessErr):
code = aclDenied
err = fmt.Errorf("%w: %s", err, accessErr.Reason())
default: default:
code = internal code = internal
} }