[SUPPORT] Introduce ChainRouterError error type and wrap only these errors with ObjectAccessDenied status #1565

Merged
fyrchik merged 3 commits from aarifullin/frostfs-node:fix/ape_logicalerr_sprt into support/v0.44 2024-12-17 08:18:09 +00:00
Showing only changes of commit 25ed595354 - Show all commits

View file

@ -1,10 +1,19 @@
package ape
import (
"errors"
checkercore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/common/ape"
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
)
func toStatusErr(err error) error {
var chRouterErr *checkercore.ChainRouterError
if !errors.As(err, &chRouterErr) {
errServerInternal := &apistatus.ServerInternal{}
apistatus.WriteInternalServerErr(errServerInternal, err)
return errServerInternal
}
errAccessDenied := &apistatus.ObjectAccessDenied{}
errAccessDenied.WriteReason("ape denied request: " + err.Error())
return errAccessDenied