[Groonga-commit] groonga/groonga-query-log at 4c817fa [master] Make error log more generic

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Mar 15 23:31:11 JST 2014


Kouhei Sutou	2014-03-15 23:31:11 +0900 (Sat, 15 Mar 2014)

  New Revision: 4c817fa0595299c93741f80fde09f1859085bda8
  https://github.com/groonga/groonga-query-log/commit/4c817fa0595299c93741f80fde09f1859085bda8

  Message:
    Make error log more generic

  Modified files:
    lib/groonga/query-log/server-verifier.rb

  Modified: lib/groonga/query-log/server-verifier.rb (+18 -11)
===================================================================
--- lib/groonga/query-log/server-verifier.rb    2014-03-15 22:39:50 +0900 (41d94b5)
+++ lib/groonga/query-log/server-verifier.rb    2014-03-15 23:31:11 +0900 (dfef48a)
@@ -64,11 +64,8 @@ module Groonga
               loop do
                 break if run_consumer
               end
-            rescue Groonga::Client::Protocol::Error
-              # TODO: add error log mechanism
-              $stderr.puts(Time.now.iso8601)
-              $stderr.puts($!.raw_error.message)
-              $stderr.puts($!.raw_error.backtrace)
+            rescue Groonga::Client::Error
+              log_client_error($!)
             end
           end
         end
@@ -83,12 +80,10 @@ module Groonga
               begin
                 verify_command(groonga1_client, groonga2_client,
                                statistic.command)
-              rescue Groonga::Client::Protocol::Error
-                # TODO: add error log mechanism
-                $stderr.puts(Time.now.iso8601)
-                $stderr.puts(statistic.command.original_source)
-                $stderr.puts($!.raw_error.message)
-                $stderr.puts($!.raw_error.backtrace)
+              rescue Groonga::Client::Error
+                log_client_error($!) do
+                  $stderr.puts(statistic.command.original_source)
+                end
                 return false
               end
             end
@@ -129,6 +124,18 @@ module Groonga
         output.puts("response2: #{response2.body}")
       end
 
+      def log_client_error(error)
+        $stderr.puts(Time.now.iso8601)
+        yield if block_given?
+        if error.respond_to?(:raw_error)
+          target_error = error.raw_error
+        else
+          target_error = error
+        end
+        $stderr.puts("#{target_error.class}: #{target_error.message}")
+        $stderr.puts(target_error.backtrace)
+      end
+
       class Options
         attr_reader :groonga1
         attr_reader :groonga2
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index