aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby
diff options
context:
space:
mode:
authorGravatar Yuan He <lendage@gmail.com>2016-11-08 10:25:30 +0800
committerGravatar Yuan He <lendage@gmail.com>2016-12-22 16:01:22 +0800
commit9383d2b809084589b677722e060ba585b536ddfa (patch)
tree6a5ff7bb94d8d4d9f9dff442d6ac08a592ea9645 /src/ruby
parentc3c1240ad5e2e7b3b25c28639ad8cf5152b19f33 (diff)
Ruby: show error class and message instead of unknown
Diffstat (limited to 'src/ruby')
-rw-r--r--src/ruby/lib/grpc/generic/rpc_desc.rb2
-rw-r--r--src/ruby/spec/generic/rpc_desc_spec.rb16
2 files changed, 12 insertions, 6 deletions
diff --git a/src/ruby/lib/grpc/generic/rpc_desc.rb b/src/ruby/lib/grpc/generic/rpc_desc.rb
index cd17aed8e7..d46c4a1b5c 100644
--- a/src/ruby/lib/grpc/generic/rpc_desc.rb
+++ b/src/ruby/lib/grpc/generic/rpc_desc.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)
diff --git a/src/ruby/spec/generic/rpc_desc_spec.rb b/src/ruby/spec/generic/rpc_desc_spec.rb
index a3f0efa603..1ace7211e9 100644
--- a/src/ruby/spec/generic/rpc_desc_spec.rb
+++ b/src/ruby/spec/generic/rpc_desc_spec.rb
@@ -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