Skip to content
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

服务不存在时,多个错误只返回第一个 #114

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions pkg/flow/sync_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,13 @@ outLoop:
sdkErrs := syncCtx.Errs()
if len(sdkErrs) > 0 {
e.reportCombinedErrs(req.GetCallResult(), consumedTime, sdkErrs)
rawErr := combineSDKErrors(sdkErrs)
log.GetBaseLogger().Errorf("error occur while processing GetInstances request,"+
" serviceKey: %s, time consume is %v, error is %s", *dstService, consumedTime, rawErr)
return model.NewSDKError(model.ErrCodeServerUserError, rawErr,
fmt.Sprintf("multierrs received for GetInstances request, serviceKey: %s", *dstService))
// 只要有一个错误就立刻返回,避免所以错误都抛出来干扰 开发者的判断。
for key, sdkErr := range sdkErrs {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议这样,全部的错误信息还是要打印到日志上,方便定位,然后只返回第一个错误

log.GetBaseLogger().Errorf("error occur while processing GetInstances request,"+
" serviceKey: %s, time consume is %v, error is %s", *dstService, consumedTime, sdkErr)
return model.NewSDKError(model.ErrCodeServerUserError, sdkErr,
fmt.Sprintf("SDKError for %s, detail is %s", key, sdkErr))
}
}
if exceedTimeout {
// 只有网络错误才可以重试
Expand Down