Lazily load protobuf from the grpc ruby errors module

pull/18964/head
Alex Polcyn 6 years ago
parent 9dcbf1053f
commit b0db0f3fb4
  1. 6
      src/ruby/lib/grpc/errors.rb

@ -13,7 +13,6 @@
# limitations under the License.
require_relative './grpc'
require_relative './google_rpc_status_utils'
# GRPC contains the General RPC module.
module GRPC
@ -58,10 +57,11 @@ module GRPC
#
# @return [Google::Rpc::Status, nil]
def to_rpc_status
# Lazily require google_rpc_status_utils to scope
# loading protobuf_c.so to the users of this method.
require_relative './google_rpc_status_utils'
status = to_status
return if status.nil?
GoogleRpcStatusUtils.extract_google_rpc_status(status)
rescue Google::Protobuf::ParseError => parse_error
GRPC.logger.warn('parse error: to_rpc_status failed')

Loading…
Cancel
Save