fixed the error translation from the statusCodeError type into a corresponding graph api Error representation
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
cs3rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
|
||||
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||
"github.com/cs3org/reva/v2/pkg/utils"
|
||||
)
|
||||
|
||||
// FromCS3Status converts a CS3 status code and an error into a corresponding local Error representation.
|
||||
@@ -69,3 +70,12 @@ func FromStat(stat *provider.StatResponse, err error, ignore ...cs3rpc.Code) err
|
||||
// TODO: look into ResourceInfo to get the postprocessing state and map that to 425 status?
|
||||
return FromCS3Status(stat.GetStatus(), err, ignore...)
|
||||
}
|
||||
|
||||
// FromUtilsStatusCodeError returns original error if `err` does not match to the statusCodeError type
|
||||
func FromUtilsStatusCodeError(err error, ignore ...cs3rpc.Code) error {
|
||||
stat := utils.StatusCodeErrorToCS3Status(err)
|
||||
if stat == nil {
|
||||
return FromCS3Status(nil, err, ignore...)
|
||||
}
|
||||
return FromCS3Status(stat, nil, ignore...)
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ func (s DriveItemPermissionsService) SpaceRootInvite(ctx context.Context, driveI
|
||||
|
||||
space, err := utils.GetSpace(ctx, storagespace.FormatResourceID(driveID), gatewayClient)
|
||||
if err != nil {
|
||||
return libregraph.Permission{}, err
|
||||
return libregraph.Permission{}, errorcode.FromUtilsStatusCodeError(err)
|
||||
}
|
||||
|
||||
if space.SpaceType != _spaceTypeProject {
|
||||
@@ -298,7 +298,7 @@ func (s DriveItemPermissionsService) ListSpaceRootPermissions(ctx context.Contex
|
||||
|
||||
space, err := utils.GetSpace(ctx, storagespace.FormatResourceID(driveID), gatewayClient)
|
||||
if err != nil {
|
||||
return collectionOfPermissions, err
|
||||
return collectionOfPermissions, errorcode.FromUtilsStatusCodeError(err)
|
||||
}
|
||||
|
||||
if space.SpaceType != _spaceTypeProject {
|
||||
@@ -371,7 +371,7 @@ func (s DriveItemPermissionsService) DeleteSpaceRootPermission(ctx context.Conte
|
||||
|
||||
space, err := utils.GetSpace(ctx, storagespace.FormatResourceID(driveID), gatewayClient)
|
||||
if err != nil {
|
||||
return err
|
||||
return errorcode.FromUtilsStatusCodeError(err)
|
||||
}
|
||||
|
||||
if space.SpaceType != _spaceTypeProject {
|
||||
@@ -422,7 +422,7 @@ func (s DriveItemPermissionsService) UpdateSpaceRootPermission(ctx context.Conte
|
||||
|
||||
space, err := utils.GetSpace(ctx, storagespace.FormatResourceID(driveID), gatewayClient)
|
||||
if err != nil {
|
||||
return libregraph.Permission{}, err
|
||||
return libregraph.Permission{}, errorcode.FromUtilsStatusCodeError(err)
|
||||
}
|
||||
|
||||
if space.SpaceType != _spaceTypeProject {
|
||||
|
||||
@@ -102,7 +102,7 @@ func (s DriveItemPermissionsService) CreateSpaceRootLink(ctx context.Context, dr
|
||||
}
|
||||
space, err := utils.GetSpace(ctx, storagespace.FormatResourceID(driveID), gatewayClient)
|
||||
if err != nil {
|
||||
return libregraph.Permission{}, err
|
||||
return libregraph.Permission{}, errorcode.FromUtilsStatusCodeError(err)
|
||||
}
|
||||
|
||||
if space.SpaceType != _spaceTypeProject {
|
||||
@@ -140,7 +140,7 @@ func (s DriveItemPermissionsService) SetPublicLinkPasswordOnSpaceRoot(ctx contex
|
||||
}
|
||||
space, err := utils.GetSpace(ctx, storagespace.FormatResourceID(driveID), gatewayClient)
|
||||
if err != nil {
|
||||
return libregraph.Permission{}, err
|
||||
return libregraph.Permission{}, errorcode.FromUtilsStatusCodeError(err)
|
||||
}
|
||||
|
||||
if space.SpaceType != _spaceTypeProject {
|
||||
|
||||
@@ -55,7 +55,7 @@ func (g BaseGraphService) getSpaceRootPermissions(ctx context.Context, spaceID *
|
||||
}
|
||||
space, err := utils.GetSpace(ctx, spaceID.GetOpaqueId(), gatewayClient)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errorcode.FromUtilsStatusCodeError(err)
|
||||
}
|
||||
|
||||
return g.cs3SpacePermissionsToLibreGraph(ctx, space, APIVersion_1_Beta_1), nil
|
||||
|
||||
Reference in New Issue
Block a user