You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/01/11 09:39:36 UTC

[GitHub] [servicecomb-service-center] yeyiwei commented on a change in pull request #824: GetService optimize

yeyiwei commented on a change in pull request #824:
URL: https://github.com/apache/servicecomb-service-center/pull/824#discussion_r554920479



##########
File path: datasource/etcd/dep.go
##########
@@ -35,23 +37,23 @@ func (ds *DataSource) SearchProviderDependency(ctx context.Context, request *pb.
 	providerServiceID := request.ServiceId
 	provider, err := serviceUtil.GetService(ctx, domainProject, providerServiceID)
 
-	if err != nil {
-		log.Errorf(err, "GetProviderDependencies failed, provider is %s", providerServiceID)
-		return nil, err
-	}
-	if provider == nil {
-		log.Errorf(err, "GetProviderDependencies failed for provider[%s] does not exist", providerServiceID)
+	if errors.Is(err, datasource.ErrNoDocuments) {

Review comment:
       之前也是嵌套判断,看代码整洁之道似乎有关于减少if嵌套的就分开写了,errors.Is(err, datasource.ErrNoDocuments)替换原来的err != nil && service == nil的情况




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org