From 8b280763f99c860aada004d1eb029d661773c4fd Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 29 Feb 2016 16:34:41 -0800 Subject: [PATCH 1/2] Add error output for failed ruby credentials plugin --- src/ruby/ext/grpc/rb_call_credentials.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ruby/ext/grpc/rb_call_credentials.c b/src/ruby/ext/grpc/rb_call_credentials.c index 2426f106a99..a32117b3cf6 100644 --- a/src/ruby/ext/grpc/rb_call_credentials.c +++ b/src/ruby/ext/grpc/rb_call_credentials.c @@ -41,6 +41,7 @@ #include #include #include +#include #include "rb_call.h" #include "rb_event_thread.h" @@ -81,14 +82,23 @@ static VALUE grpc_rb_call_credentials_callback(VALUE callback_args) { static VALUE grpc_rb_call_credentials_callback_rescue(VALUE args, VALUE exception_object) { VALUE result = rb_hash_new(); + VALUE backtrace = rb_funcall( + rb_ivar_get(exception_object, rb_intern("backtrace")), + rb_intern("join"), + 1, rb_str_new2("\n\tfrom ")); + VALUE exception_info = rb_funcall(exception_object, rb_intern("to_s"), 0); + const char *exception_classname = rb_obj_classname(exception_object); (void)args; + gpr_log(GPR_INFO, "Call credentials callback failed: %s %s\n%s", + exception_classname, StringValueCStr(exception_info), + StringValueCStr(backtrace)); rb_hash_aset(result, rb_str_new2("metadata"), Qnil); /* Currently only gives the exception class name. It should be possible get more details */ rb_hash_aset(result, rb_str_new2("status"), INT2NUM(GRPC_STATUS_PERMISSION_DENIED)); rb_hash_aset(result, rb_str_new2("details"), - rb_str_new2(rb_obj_classname(exception_object))); + rb_str_new2(exception_classname)); return result; } From 011641bb13db752413b8cc188e2200a60943ea80 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 29 Feb 2016 17:36:10 -0800 Subject: [PATCH 2/2] Minor fix to backtrace retreival code --- src/ruby/ext/grpc/rb_call_credentials.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ruby/ext/grpc/rb_call_credentials.c b/src/ruby/ext/grpc/rb_call_credentials.c index a32117b3cf6..c7697f46280 100644 --- a/src/ruby/ext/grpc/rb_call_credentials.c +++ b/src/ruby/ext/grpc/rb_call_credentials.c @@ -83,13 +83,13 @@ static VALUE grpc_rb_call_credentials_callback_rescue(VALUE args, VALUE exception_object) { VALUE result = rb_hash_new(); VALUE backtrace = rb_funcall( - rb_ivar_get(exception_object, rb_intern("backtrace")), + rb_funcall(exception_object, rb_intern("backtrace"), 0), rb_intern("join"), 1, rb_str_new2("\n\tfrom ")); VALUE exception_info = rb_funcall(exception_object, rb_intern("to_s"), 0); const char *exception_classname = rb_obj_classname(exception_object); (void)args; - gpr_log(GPR_INFO, "Call credentials callback failed: %s %s\n%s", + gpr_log(GPR_INFO, "Call credentials callback failed: %s: %s\n%s", exception_classname, StringValueCStr(exception_info), StringValueCStr(backtrace)); rb_hash_aset(result, rb_str_new2("metadata"), Qnil);