Merge pull request #8668 from lenage/master

Ruby: show error class and message instead of unknown
pull/9193/head
apolcyn 8 years ago committed by GitHub
commit 7376d4b97e
  1. 2
      src/ruby/lib/grpc/generic/rpc_desc.rb
  2. 16
      src/ruby/spec/generic/rpc_desc_spec.rb

@ -119,7 +119,7 @@ module GRPC
# Send back a UNKNOWN status to the client
GRPC.logger.warn("failed handler: #{active_call}; sending status:UNKNOWN")
GRPC.logger.warn(e)
send_status(active_call, UNKNOWN, 'unkown error handling call on server')
send_status(active_call, UNKNOWN, "#{e.class}: #{e.message}")
end
def assert_arity_matches(mth)

@ -48,7 +48,6 @@ describe GRPC::RpcDesc do
@bidi_streamer = RpcDesc.new('ss', Stream.new(Object.new),
Stream.new(Object.new), 'encode', 'decode')
@bs_code = INTERNAL
@no_reason = 'unkown error handling call on server'
@ok_response = Object.new
end
@ -62,8 +61,9 @@ describe GRPC::RpcDesc do
it 'sends status UNKNOWN if other StandardErrors are raised' do
expect(@call).to receive(:remote_read).once.and_return(Object.new)
expect(@call).to receive(:send_status) .once.with(UNKNOWN, @no_reason,
false, metadata: {})
expect(@call).to receive(:send_status).once.with(UNKNOWN,
arg_error_msg,
false, metadata: {})
this_desc.run_server_method(@call, method(:other_error))
end
@ -112,7 +112,7 @@ describe GRPC::RpcDesc do
end
it 'sends status UNKNOWN if other StandardErrors are raised' do
expect(@call).to receive(:send_status).once.with(UNKNOWN, @no_reason,
expect(@call).to receive(:send_status).once.with(UNKNOWN, arg_error_msg,
false, metadata: {})
@client_streamer.run_server_method(@call, method(:other_error_alt))
end
@ -174,8 +174,9 @@ describe GRPC::RpcDesc do
end
it 'sends status UNKNOWN if other StandardErrors are raised' do
error_msg = arg_error_msg(StandardError.new)
expect(@call).to receive(:run_server_bidi).and_raise(StandardError)
expect(@call).to receive(:send_status).once.with(UNKNOWN, @no_reason,
expect(@call).to receive(:send_status).once.with(UNKNOWN, error_msg,
false, metadata: {})
@bidi_streamer.run_server_method(@call, method(:other_error_alt))
end
@ -342,4 +343,9 @@ describe GRPC::RpcDesc do
def other_error_alt(_call)
fail(ArgumentError, 'other error')
end
def arg_error_msg(error = nil)
error ||= ArgumentError.new('other error')
"#{error.class}: #{error.message}"
end
end

Loading…
Cancel
Save