forked from TrueCloudLab/frostfs-node
Airat Arifullin
1a091ea7bb
* Such wrapping helps to differentiate logical check errors and server internal errors. Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
20 lines
594 B
Go
20 lines
594 B
Go
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
|
|
}
|