Skip to content
Snippets Groups Projects
Commit d9f59b28 authored by vito.he's avatar vito.he
Browse files

Fix: error return msg not include service name

parent 9eb0e81d
No related branches found
No related tags found
No related merge requests found
...@@ -93,7 +93,7 @@ func (invoker *failoverClusterInvoker) Invoke(invocation protocol.Invocation) pr ...@@ -93,7 +93,7 @@ func (invoker *failoverClusterInvoker) Invoke(invocation protocol.Invocation) pr
} }
} }
ip, _ := utils.GetLocalIP() ip, _ := utils.GetLocalIP()
return &protocol.RPCResult{Err: perrors.Errorf("Failed to invoke the method %v in the service %v . Tried %v times of "+ 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.", "the providers %v (%v/%v)from the registry %v on the consumer %v using the dubbo version %v. Last error is %v.",
methodName, invoker.GetUrl().Service(), retries, providers, len(providers), len(invokers), invoker.directory.GetUrl(), ip, version.Version, result.Error().Error(), methodName, invoker.GetUrl().Service(), retries, providers, len(providers), len(invokers), invoker.directory.GetUrl(), ip, version.Version, result.Error().Error(),
)} )}
......
...@@ -25,8 +25,13 @@ type staticDirectory struct { ...@@ -25,8 +25,13 @@ type staticDirectory struct {
} }
func NewStaticDirectory(invokers []protocol.Invoker) *staticDirectory { func NewStaticDirectory(invokers []protocol.Invoker) *staticDirectory {
var url common.URL
if len(invokers) > 0 {
url = invokers[0].GetUrl()
}
return &staticDirectory{ return &staticDirectory{
BaseDirectory: NewBaseDirectory(&common.URL{}), BaseDirectory: NewBaseDirectory(&url),
invokers: invokers, invokers: invokers,
} }
} }
......
...@@ -248,7 +248,16 @@ func (c URL) Context() context.Context { ...@@ -248,7 +248,16 @@ func (c URL) Context() context.Context {
} }
func (c URL) Service() string { func (c URL) Service() string {
return strings.TrimPrefix(c.Path, "/") service := strings.TrimPrefix(c.Path, "/")
if service != "" {
return service
} else if c.SubURL != nil {
service = strings.TrimPrefix(c.SubURL.Path, "/")
if service != "" { //if url.path is "" then return suburl's path, special for registry Url
return service
}
}
return ""
} }
func (c URL) GetParam(s string, d string) string { func (c URL) GetParam(s string, d string) string {
var r string var r string
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment