[Groonga-commit] droonga/droonga-engine at 08f6a1c [master] Handle Droonga communication errors while absorbing for readability of exceptions

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Mar 27 13:43:09 JST 2015


YUKI Hiroshi	2015-03-27 13:43:09 +0900 (Fri, 27 Mar 2015)

  New Revision: 08f6a1c3fe138bd9c34f64d4e68f0523874fa483
  https://github.com/droonga/droonga-engine/commit/08f6a1c3fe138bd9c34f64d4e68f0523874fa483

  Message:
    Handle Droonga communication errors while absorbing for readability of exceptions

  Modified files:
    lib/droonga/data_absorber.rb

  Modified: lib/droonga/data_absorber.rb (+14 -0)
===================================================================
--- lib/droonga/data_absorber.rb    2015-03-27 13:36:42 +0900 (bdb2bb4)
+++ lib/droonga/data_absorber.rb    2015-03-27 13:43:09 +0900 (691b1e2)
@@ -24,6 +24,12 @@ module Droonga
   class DataAbsorber
     include Loggable
 
+    class EmptyResponse < StandardError
+    end
+
+    class EmptyBody < StandardError
+    end
+
     DEFAULT_MESSAGES_PER_SECOND = 100
 
     TIME_UNKNOWN = -1
@@ -207,6 +213,10 @@ module Droonga
     def source_tables
       response = source_client.request("dataset" => @dataset,
                                        "type"    => "table_list")
+
+      raise EmptyResponse("table_list") unless response
+      raise EmptyBody("table_list") unless response["body"]
+
       message_body = response["body"]
       body = message_body[1]
       tables = body[1..-1]
@@ -230,6 +240,10 @@ module Droonga
                                        "body"    => {
                                          "queries" => queries,
                                        })
+
+      raise EmptyResponse("search") unless response
+      raise EmptyBody("search") unless response["body"]
+
       n_records = 0
       response["body"].each do |query_name, result|
         n_records += result["count"]
-------------- next part --------------
HTML����������������������������...
下载 



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