Log ParseError raised in BadStatus#to_rpc_status

pull/18752/head
Mike Moore 6 years ago
parent 0fa7cf9194
commit b47f2048b8
No known key found for this signature in database
GPG Key ID: DD7A8E4072BD187A
  1. 4
      src/ruby/lib/grpc/errors.rb
  2. 8
      src/ruby/spec/errors_spec.rb

@ -63,7 +63,9 @@ module GRPC
return if status.nil?
GoogleRpcStatusUtils.extract_google_rpc_status(status)
rescue
rescue Google::Protobuf::ParseError => parse_error
GRPC.logger.warn('parse error: to_rpc_status failed')
GRPC.logger.warn(parse_error)
nil
end

@ -127,6 +127,14 @@ describe GRPC::BadStatus do
exception = GRPC::BadStatus.new(code, details, metadata)
expect(exception.to_rpc_status).to be nil
# Check that the parse error was logged correctly
log_contents = @log_output.read
expected_line_1 = 'WARN GRPC : parse error: to_rpc_status failed'
expected_line_2 = 'WARN GRPC : <Google::Protobuf::ParseError> ' \
'Error occurred during parsing: Invalid wire type'
expect(log_contents).to include expected_line_1
expect(log_contents).to include expected_line_2
end
end
end

Loading…
Cancel
Save