-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate using errors.New and fmt.Errorf (#1673) #1680
Conversation
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes. |
@gmgigi96 thanks a lot for the change! Can you update the appprovider unit tests to expect the updated message? We can merge it then |
@@ -131,7 +132,7 @@ func (s *service) getWopiAppEndpoints(ctx context.Context) (map[string]interface | |||
} | |||
defer appsRes.Body.Close() | |||
if appsRes.StatusCode != http.StatusOK { | |||
return nil, fmt.Errorf("Request to WOPI server returned %d", appsRes.StatusCode) | |||
return nil, errtypes.PermissionDenied(fmt.Sprintf("Request to WOPI server returned %d", appsRes.StatusCode)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to InternalError
@@ -263,7 +264,7 @@ func (s *service) OpenFileInAppProvider(ctx context.Context, req *providerpb.Ope | |||
} | |||
defer bridgeRes.Body.Close() | |||
if bridgeRes.StatusCode != http.StatusFound { | |||
return nil, fmt.Errorf("Request to WOPI bridge returned %d", bridgeRes.StatusCode) | |||
return nil, errtypes.PermissionDenied(fmt.Sprintf("Request to WOPI bridge returned %d", bridgeRes.StatusCode)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to InternalError
@@ -66,12 +66,12 @@ func parseConfig(m map[string]interface{}) (*config, error) { | |||
|
|||
func getAuthManager(manager string, m map[string]map[string]interface{}) (auth.Manager, error) { | |||
if manager == "" { | |||
return nil, errors.New("authsvc: driver not configured for auth manager") | |||
return nil, errtypes.NotFound("authsvc: driver not configured for auth manager") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to InternalError
@@ -246,7 +246,7 @@ func (s *svc) findAppProvider(ctx context.Context, ri *storageprovider.ResourceI | |||
return nil, errtypes.NotFound("gateway: app provider not found for resource: " + ri.String()) | |||
} | |||
|
|||
return nil, errors.New("gateway: error finding a storage provider") | |||
return nil, errtypes.NotFound("gateway: error finding a storage provider") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to InternalError, NotFound will be handled by the check above
@@ -191,5 +191,5 @@ func (s *svc) findAuthProvider(ctx context.Context, authType string) (provider.P | |||
return nil, errtypes.NotFound("gateway: auth provider not found for type:" + authType) | |||
} | |||
|
|||
return nil, errors.New("gateway: error finding an auth provider for type: " + authType) | |||
return nil, errtypes.NotFound("gateway: error finding an auth provider for type: " + authType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to InternalError, NotFound will be handled by the check above
}, nil | ||
} | ||
|
||
var permissions string | ||
permOpaque, ok := req.Opaque.Map["permissions"] | ||
if !ok { | ||
return &ocm.CreateOCMShareResponse{ | ||
Status: status.NewInternal(ctx, errors.New("resource permissions not set"), ""), | ||
Status: status.NewInternal(ctx, errtypes.NotFound("resource permissions not set"), ""), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BadRequest
@@ -131,14 +131,14 @@ func (s *service) CreateOCMShare(ctx context.Context, req *ocm.CreateOCMShareReq | |||
nameOpaque, ok := req.Opaque.Map["name"] | |||
if !ok { | |||
return &ocm.CreateOCMShareResponse{ | |||
Status: status.NewInternal(ctx, errors.New("resource name not set"), ""), | |||
Status: status.NewInternal(ctx, errtypes.NotFound("resource name not set"), ""), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BadRequest
@@ -116,7 +116,7 @@ func parseXSTypes(xsTypes map[string]uint32) ([]*provider.ResourceChecksumPriori | |||
for xs, prio := range xsTypes { | |||
t := PKG2GRPCXS(xs) | |||
if t == provider.ResourceChecksumType_RESOURCE_CHECKSUM_TYPE_INVALID { | |||
return nil, fmt.Errorf("checksum type is invalid: %s", xs) | |||
return nil, errtypes.NotFound("checksum type is invalid: " + xs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BadRequest
@@ -299,7 +299,7 @@ func (s *service) InitiateFileUpload(ctx context.Context, req *provider.Initiate | |||
} | |||
if newRef.GetPath() == "/" { | |||
return &provider.InitiateFileUploadResponse{ | |||
Status: status.NewInternal(ctx, errors.New("can't upload to mount path"), "can't upload to mount path"), | |||
Status: status.NewInternal(ctx, errtypes.InternalError("can't upload to mount path"), "can't upload to mount path"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BadRequest
@@ -486,7 +486,7 @@ func (s *service) Delete(ctx context.Context, req *provider.DeleteRequest) (*pro | |||
} | |||
if newRef.GetPath() == "/" { | |||
return &provider.DeleteResponse{ | |||
Status: status.NewInternal(ctx, errors.New("can't delete mount path"), "can't delete mount path"), | |||
Status: status.NewInternal(ctx, errtypes.InternalError("can't delete mount path"), "can't delete mount path"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BadRequest
Closes #1673