Introduce ChainRouterError
error type and wrap only these errors with ObjectAccessDenied
status #1563
1 changed files with 9 additions and 0 deletions
|
@ -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{}
|
||||
fyrchik marked this conversation as resolved
Outdated
|
||||
apistatus.WriteInternalServerErr(errServerInternal, err)
|
||||
return errServerInternal
|
||||
}
|
||||
errAccessDenied := &apistatus.ObjectAccessDenied{}
|
||||
errAccessDenied.WriteReason("ape denied request: " + err.Error())
|
||||
return errAccessDenied
|
||||
|
|
Loading…
Add table
Reference in a new issue
Where do we do wrapping to internal status (if we have any)?
I am wondering whether these changes may break client code (see
PrmInit.ResolveFrostFSFailures()
in SDK), because we will get an error instead of status.We don't do that for all errors, but they are implicitly (from the point of this middleware) wrapped to
internalServerError
anyway. Aren't they?Although that's not true for
tree
serviceFor now non-
chainRouterError
errors are explicitly wrapped with ServerInternal status for the all goodness sake