Skip to content
Snippets Groups Projects
Commit 00f9946d authored by cvictory's avatar cvictory
Browse files

modify return error and log

parent 6920c158
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,7 @@ package cluster_impl
import (
"context"
"fmt"
"strconv"
)
......@@ -91,8 +92,10 @@ func (invoker *failoverClusterInvoker) Invoke(ctx context.Context, invocation pr
invokerSvc := invoker.GetUrl().Service()
invokerUrl := invoker.directory.GetUrl()
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.",
methodName, invokerSvc, retries, providers, len(providers), len(invokers), invokerUrl, ip, constant.Version, result.Error().Error(),
Err: perrors.Wrap(result.Error(), fmt.Sprintf("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.", methodName, invokerSvc, retries, providers, len(providers), len(invokers),
invokerUrl, ip, constant.Version, result.Error().Error()),
)}
}
......
......@@ -23,6 +23,11 @@ import (
"sync"
)
import (
"github.com/apache/dubbo-go-hessian2/java_exception"
perrors "github.com/pkg/errors"
)
import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
......@@ -154,7 +159,17 @@ func (p *Proxy) Implement(v common.RPCService) {
}
err = result.Error()
logger.Debugf("[makeDubboCallProxy] result: %v, err: %v", result.Result(), err)
if err != nil {
// 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())
} else {
logger.Errorf("result err: %v", err)
}
} else {
logger.Debugf("[makeDubboCallProxy] result: %v, err: %v", result.Result(), err)
}
if len(outs) == 1 {
return []reflect.Value{reflect.ValueOf(&err).Elem()}
}
......
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