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

Fix : the consumer cannot get the real cause error from provider #652

Merged
merged 5 commits into from
Jul 22, 2020

Conversation

cvictory
Copy link
Contributor

1.现在中间件的返回值
代码中的样子:

// 来自于proxy
return &protocol.RPCResult{		return &protocol.RPCResult{
		Err: perrors.Errorf("Failed to invoke the method %v in the service %v. Tried %v times of the providers %v (%v/%v)from the registry %v on the consumer %v using the dubbo version %v. Last error is %v.",			Err: perrors.Wrap(result.Error(), fmt.Sprintf("Failed to invoke the method %v in the service %v. "+
			methodName, invokerSvc, retries, providers, len(providers), len(invokers), invokerUrl, ip, constant.Version, result.Error().Error(),				"Tried %v times of the providers %v (%v/%v)from the registry %v on the consumer %v using the dubbo version %v. "+
			"Last error is %+v.", methodName, invokerSvc, retries, providers, len(providers), len(invokers),
			invokerUrl, ip, constant.Version, result.Error().Error()),
		)}

应用中的返回值:
image

说明原始的error丢失了,所以这个需要能够包装,应用中可以获取的cause。 这样,server端抛出来的异常才能被解析到。

  1. 日志修改

// the cause reason
err = perrors.Cause(err)
if throwabler, ok := err.(java_exception.Throwabler); ok {
logger.Errorf("invoke service throw exception: %v , stackTraceElements: %v", err.Error(), throwabler.GetStackTrace())
Copy link
Member

Choose a reason for hiding this comment

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

有错误不需要打error日志,用warn或者info即可

} else {
logger.Errorf("result err: %v", err)
}
} else {
Copy link
Member

Choose a reason for hiding this comment

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

建议else能去则去掉下

Copy link
Contributor

@hxmhlt hxmhlt left a comment

Choose a reason for hiding this comment

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

LGTM

@zouyx
Copy link
Member

zouyx commented Jul 14, 2020

Travis still failing

Copy link
Member

@zouyx zouyx left a comment

Choose a reason for hiding this comment

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

I have retriggered travis to fix the problem

@AlexStocks AlexStocks merged commit 053aab5 into apache:develop Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants