forked from TrueCloudLab/frostfs-s3-gw
[#519] Fix transform of AcessDenied error
Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
cb5237fb82
commit
87d19f09f7
1 changed files with 10 additions and 0 deletions
|
@ -268,6 +268,10 @@ func (x *NeoFS) CreateObject(ctx context.Context, prm layer.PrmObjectCreate) (*o
|
|||
|
||||
idObj, err := x.pool.PutObject(ctx, prmPut)
|
||||
if err != nil {
|
||||
reason, ok := isErrAccessDenied(err)
|
||||
if ok {
|
||||
return nil, fmt.Errorf("%w: %s", layer.ErrAccessDenied, reason)
|
||||
}
|
||||
return nil, fmt.Errorf("save object via connection pool: %w", err)
|
||||
}
|
||||
|
||||
|
@ -467,6 +471,12 @@ func (x *NeoFS) DeleteObject(ctx context.Context, prm layer.PrmObjectDelete) err
|
|||
}
|
||||
|
||||
func isErrAccessDenied(err error) (string, bool) {
|
||||
unwrappedErr := errors.Unwrap(err)
|
||||
for unwrappedErr != nil {
|
||||
err = unwrappedErr
|
||||
unwrappedErr = errors.Unwrap(err)
|
||||
}
|
||||
|
||||
switch err := err.(type) {
|
||||
default:
|
||||
return "", false
|
||||
|
|
Loading…
Reference in a new issue