made change backwards compatible

This commit is contained in:
Mikhail Katychev 2020-09-29 18:17:34 -05:00
parent 1e796ea75f
commit 064101bc06
No known key found for this signature in database
GPG Key ID: 9E8549CD2CEB5E59
2 changed files with 4 additions and 4 deletions

View File

@ -695,7 +695,7 @@ func main() {
err = grpcurl.InvokeRPC(ctx, descSource, cc, symbol, append(addlHeaders, rpcHeaders...), h, rf.Next)
if err != nil {
if errStatus, ok := status.FromError(err); ok {
if errStatus, ok := status.FromError(err); ok && *formatError {
h.Status = errStatus
} else {
fail(err, "Error invoking method %q", symbol)

View File

@ -99,9 +99,9 @@ func InvokeRPC(ctx context.Context, source DescriptorSource, ch grpcdynamic.Chan
if isNotFoundError(err) {
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 the error unstringified if it is a gRPC status error
if statusErr, ok := status.FromError(err); ok {
return status.Errorf(statusErr.Code(), "failed to query for service descriptor %q: %v", svc, err)
}
return fmt.Errorf("failed to query for service descriptor %q: %v", svc, err)
}