[Groonga-commit] droonga/droonga-client-ruby at 2cf5b98 [master] Wrap error by class

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Apr 15 20:11:37 JST 2015


YUKI Hiroshi	2015-04-15 20:11:37 +0900 (Wed, 15 Apr 2015)

  New Revision: 2cf5b98378dc7c1bcea5da8162ec9b397555aade
  https://github.com/droonga/droonga-client-ruby/commit/2cf5b98378dc7c1bcea5da8162ec9b397555aade

  Message:
    Wrap error by class

  Modified files:
    lib/droonga/client.rb
    lib/droonga/client/connection/droonga-protocol.rb
    lib/droonga/client/connection/droonga-protocol/coolio.rb
    lib/droonga/client/connection/droonga-protocol/thread.rb

  Modified: lib/droonga/client.rb (+7 -1)
===================================================================
--- lib/droonga/client.rb    2015-04-15 19:27:30 +0900 (fe9be4d)
+++ lib/droonga/client.rb    2015-04-15 20:11:37 +0900 (f9c0bc3)
@@ -33,6 +33,12 @@ module Droonga
 
     attr_writer :on_error
 
+    class ConnectionError < StandardError
+      def initialize(error)
+        super(error.inspect)
+      end
+    end
+
     class << self
       # Opens a new connection and yields a {Client} object to use the
       # connection. The client is closed after the given block is
@@ -77,7 +83,7 @@ module Droonga
     def initialize(options={})
       @connection = create_connection(options)
       @connection.on_error = lambda do |error|
-        on_error(error)
+        on_error(ConnectionError.new(error))
       end
 
       @completion = options[:completion] != false

  Modified: lib/droonga/client/connection/droonga-protocol.rb (+7 -1)
===================================================================
--- lib/droonga/client/connection/droonga-protocol.rb    2015-04-15 19:27:30 +0900 (0416ee7)
+++ lib/droonga/client/connection/droonga-protocol.rb    2015-04-15 20:11:37 +0900 (e063312)
@@ -21,6 +21,12 @@ module Droonga
   class Client
     module Connection
       class DroongaProtocol
+        class BackendError < StandardError
+          def initialize(error)
+            super(error.inspect)
+          end
+        end
+
         attr_writer :on_error
 
         def initialize(options={})
@@ -30,7 +36,7 @@ module Droonga
           @options = options
           @backend = create_backend
           @backend.on_error = lambda do |error|
-            on_error(error)
+            on_error(BackendError.new(error))
           end
         end
 

  Modified: lib/droonga/client/connection/droonga-protocol/coolio.rb (+9 -3)
===================================================================
--- lib/droonga/client/connection/droonga-protocol/coolio.rb    2015-04-15 19:27:30 +0900 (8ff9dee)
+++ lib/droonga/client/connection/droonga-protocol/coolio.rb    2015-04-15 20:11:37 +0900 (cb7d2db)
@@ -23,6 +23,12 @@ module Droonga
         class Coolio
           attr_writer :on_error
 
+          class ReceiverError < StandardError
+            def initialize(error)
+              super(error.inspect)
+            end
+          end
+
           class NilMessage < StandardError
           end
 
@@ -166,11 +172,11 @@ module Droonga
               on_read = lambda do |data|
                 unpacker.feed_each(data) do |fluent_message|
                   unless fluent_message
-                    on_error(NilMessage.new("unpacker.feed_each"))
+                    on_error(NilMessage.new("coolio / unpacker.feed_each"))
                   end
                   tag, time, droonga_message = fluent_message
                   unless droonga_message
-                    on_error(NilMessage.new("unpacker.feed_each",
+                    on_error(NilMessage.new("coolio / unpacker.feed_each",
                                             :fluent_message => fluent_message.inspect))
                   end
                   id = droonga_message["inReplyTo"]
@@ -218,7 +224,7 @@ module Droonga
             @receiver_port = @options[:receiver_port] || 0
             @receiver = Receiver.new(@receiver_host, @receiver_port)
             @receiver.on_error = lambda do |error|
-              on_error(error)
+              on_error(ReceiverError.new(error))
             end
             @receiver.attach(@loop)
           end

  Modified: lib/droonga/client/connection/droonga-protocol/thread.rb (+7 -1)
===================================================================
--- lib/droonga/client/connection/droonga-protocol/thread.rb    2015-04-15 19:27:30 +0900 (6dc0d24)
+++ lib/droonga/client/connection/droonga-protocol/thread.rb    2015-04-15 20:11:37 +0900 (9ff0135)
@@ -27,6 +27,12 @@ module Droonga
 
           attr_writer :on_error
 
+          class ReceiverError < StandardError
+            def initialize(error)
+              super(error.inspect)
+            end
+          end
+
           class NilMessage < StandardError
           end
 
@@ -55,7 +61,7 @@ module Droonga
           def request(message, options={}, &block)
             receiver = create_receiver
             receiver.on_error = lambda do |error|
-              on_error(error)
+              on_error(ReceiverError.new(error))
             end
             message = message.dup
             message["replyTo"] = "#{receiver.host}:#{receiver.port}/droonga"
-------------- next part --------------
HTML����������������������������...
下載 



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