mirror of
https://github.com/owncloud/ocis
synced 2026-04-26 01:35:25 +02:00
always use error interface when returning errors (#8816)
* always use error interface when returning errors Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * fix: use non pointer Error * fix: errorcode evaluation --------- Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> Co-authored-by: Florian Schade <f.schade@icloud.com>
This commit is contained in:
committed by
GitHub
parent
fad37db840
commit
7a635738fa
@@ -21,13 +21,14 @@ import (
|
||||
"github.com/cs3org/reva/v2/pkg/storagespace"
|
||||
"github.com/cs3org/reva/v2/pkg/utils"
|
||||
libregraph "github.com/owncloud/libre-graph-api-go"
|
||||
"google.golang.org/protobuf/types/known/fieldmaskpb"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/config"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/errorcode"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/identity"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/linktype"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/unifiedrole"
|
||||
"google.golang.org/protobuf/types/known/fieldmaskpb"
|
||||
)
|
||||
|
||||
// BaseGraphService implements a couple of helper functions that are
|
||||
@@ -424,8 +425,8 @@ func (g BaseGraphService) getCS3PublicShareByID(ctx context.Context, permissionI
|
||||
},
|
||||
},
|
||||
)
|
||||
if errCode := errorcode.FromCS3Status(getPublicShareResp.GetStatus(), err); errCode != nil {
|
||||
return nil, *errCode
|
||||
if err := errorcode.FromCS3Status(getPublicShareResp.GetStatus(), err); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return getPublicShareResp.GetShare(), nil
|
||||
}
|
||||
@@ -447,8 +448,8 @@ func (g BaseGraphService) removePublicShare(ctx context.Context, permissionID st
|
||||
},
|
||||
},
|
||||
})
|
||||
if errcode := errorcode.FromCS3Status(removePublicShareResp.GetStatus(), err); errcode != nil {
|
||||
return *errcode
|
||||
if err := errorcode.FromCS3Status(removePublicShareResp.GetStatus(), err); err != nil {
|
||||
return err
|
||||
}
|
||||
// We need to return an untyped nil here otherwise the error==nil check won't work
|
||||
return nil
|
||||
@@ -472,8 +473,8 @@ func (g BaseGraphService) removeUserShare(ctx context.Context, permissionID stri
|
||||
},
|
||||
})
|
||||
|
||||
if errCode := errorcode.FromCS3Status(removeShareResp.GetStatus(), err); errCode != nil {
|
||||
return *errCode
|
||||
if err := errorcode.FromCS3Status(removeShareResp.GetStatus(), err); err != nil {
|
||||
return err
|
||||
}
|
||||
// We need to return an untyped nil here otherwise the error==nil check won't work
|
||||
return nil
|
||||
@@ -501,8 +502,8 @@ func (g BaseGraphService) removeSpacePermission(ctx context.Context, permissionI
|
||||
},
|
||||
})
|
||||
|
||||
if errCode := errorcode.FromCS3Status(removeShareResp.GetStatus(), err); errCode != nil {
|
||||
return *errCode
|
||||
if err := errorcode.FromCS3Status(removeShareResp.GetStatus(), err); err != nil {
|
||||
return err
|
||||
}
|
||||
// We need to return an untyped nil here otherwise the error==nil check won't work
|
||||
return nil
|
||||
@@ -533,8 +534,8 @@ func (g BaseGraphService) getCS3UserShareByID(ctx context.Context, permissionID
|
||||
},
|
||||
},
|
||||
})
|
||||
if errCode := errorcode.FromCS3Status(getShareResp.GetStatus(), err); errCode != nil {
|
||||
return nil, *errCode
|
||||
if err := errorcode.FromCS3Status(getShareResp.GetStatus(), err); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return getShareResp.GetShare(), nil
|
||||
}
|
||||
@@ -683,8 +684,8 @@ func (g BaseGraphService) updateUserShare(ctx context.Context, permissionID stri
|
||||
}
|
||||
|
||||
updateUserShareResp, err := gatewayClient.UpdateShare(ctx, &cs3UpdateShareReq)
|
||||
if errCode := errorcode.FromCS3Status(updateUserShareResp.GetStatus(), err); errCode != nil {
|
||||
return nil, *errCode
|
||||
if err := errorcode.FromCS3Status(updateUserShareResp.GetStatus(), err); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
permission, err := g.cs3UserShareToPermission(ctx, updateUserShareResp.GetShare(), condition)
|
||||
|
||||
Reference in New Issue
Block a user