[#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 (
_ = iota
internal
aclDenied
)
var (
code int
internalErr = new(sdkstatus.ServerInternal)
accessErr = new(sdkstatus.ObjectAccessDenied)
)
switch {
case errors.As(err, &internalErr):
code = internal
case errors.As(err, &accessErr):
code = aclDenied
err = fmt.Errorf("%w: %s", err, accessErr.Reason())
default:
code = internal
}