propagate reflection status error
This commit is contained in:
parent
9846afccbc
commit
1e796ea75f
|
|
@ -695,7 +695,11 @@ func main() {
|
||||||
|
|
||||||
err = grpcurl.InvokeRPC(ctx, descSource, cc, symbol, append(addlHeaders, rpcHeaders...), h, rf.Next)
|
err = grpcurl.InvokeRPC(ctx, descSource, cc, symbol, append(addlHeaders, rpcHeaders...), h, rf.Next)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fail(err, "Error invoking method %q", symbol)
|
if errStatus, ok := status.FromError(err); ok {
|
||||||
|
h.Status = errStatus
|
||||||
|
} else {
|
||||||
|
fail(err, "Error invoking method %q", symbol)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reqSuffix := ""
|
reqSuffix := ""
|
||||||
respSuffix := ""
|
respSuffix := ""
|
||||||
|
|
|
||||||
|
|
@ -93,11 +93,16 @@ func InvokeRPC(ctx context.Context, source DescriptorSource, ch grpcdynamic.Chan
|
||||||
if svc == "" || mth == "" {
|
if svc == "" || mth == "" {
|
||||||
return fmt.Errorf("given method name %q is not in expected format: 'service/method' or 'service.method'", methodName)
|
return fmt.Errorf("given method name %q is not in expected format: 'service/method' or 'service.method'", methodName)
|
||||||
}
|
}
|
||||||
|
|
||||||
dsc, err := source.FindSymbol(svc)
|
dsc, err := source.FindSymbol(svc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if isNotFoundError(err) {
|
if isNotFoundError(err) {
|
||||||
return fmt.Errorf("target server does not expose service %q", svc)
|
return fmt.Errorf("target server does not expose service %q", svc)
|
||||||
}
|
}
|
||||||
|
// return the error unstringified if it is a gRPC status.Status error
|
||||||
|
if _, ok := status.FromError(err); ok {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return fmt.Errorf("failed to query for service descriptor %q: %v", svc, err)
|
return fmt.Errorf("failed to query for service descriptor %q: %v", svc, err)
|
||||||
}
|
}
|
||||||
sd, ok := dsc.(*desc.ServiceDescriptor)
|
sd, ok := dsc.(*desc.ServiceDescriptor)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue