[前][次][番号順一覧][スレッド一覧]

ruby-changes:41888

From: seki <ko1@a...>
Date: Sun, 28 Feb 2016 20:28:12 +0900 (JST)
Subject: [ruby-changes:41888] seki:r53962 (trunk): * lib/drb/drb.rb (error_print): Add verbose failure messages and

seki	2016-02-28 20:28:58 +0900 (Sun, 28 Feb 2016)

  New Revision: 53962

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53962

  Log:
    * lib/drb/drb.rb (error_print): Add verbose failure messages and
      avoid infamous DRb::DRbConnError. [Feature #12101]

  Modified files:
    trunk/ChangeLog
    trunk/lib/drb/drb.rb
Index: lib/drb/drb.rb
===================================================================
--- lib/drb/drb.rb	(revision 53961)
+++ lib/drb/drb.rb	(revision 53962)
@@ -1632,6 +1632,17 @@ module DRb https://github.com/ruby/ruby/blob/trunk/lib/drb/drb.rb#L1632
       include InvokeMethod18Mixin
     end
 
+    def error_print(exception)
+      exception.backtrace.inject(true) do |first, x|
+        if first
+          $stderr.puts "#{x}: #{exception} (#{exception.class})" 
+        else
+          $stderr.puts "\tfrom #{x}"
+        end
+        false
+      end
+    end
+
     # The main loop performed by a DRbServer's internal thread.
     #
     # Accepts a connection from a client, and starts up its own
@@ -1655,13 +1666,10 @@ module DRb https://github.com/ruby/ruby/blob/trunk/lib/drb/drb.rb#L1666
             succ = false
             invoke_method = InvokeMethod.new(self, client)
             succ, result = invoke_method.perform
-            if !succ && verbose
-              p result
-              result.backtrace.each do |x|
-                puts x
-              end
-            end
-            client.send_reply(succ, result) rescue nil
+            error_print(result) if !succ && verbose
+            client.send_reply(succ, result)
+          rescue Exception => e
+            error_print(e) if verbose
           ensure
             client.close unless succ
             if Thread.current['DRb']['stop_service']
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53961)
+++ ChangeLog	(revision 53962)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Feb 28 20:23:36 2016  Masatoshi SEKI  <m_seki@m...>
+
+	* lib/drb/drb.rb (error_print): Add verbose failure messages and
+	  avoid infamous DRb::DRbConnError. [Feature #12101]
+
 Sun Feb 28 13:40:46 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* error.c (nometh_err_initialize): add private_call? parameter.

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]