[Groonga-commit] droonga/fluent-plugin-droonga at 352e712 [master] Define error classes under the namespace "Droonga::ErrorMessage"

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Feb 19 15:50:51 JST 2014


YUKI Hiroshi	2014-02-19 15:50:51 +0900 (Wed, 19 Feb 2014)

  New Revision: 352e712043595b3c14684fa7d386d217220be8f8
  https://github.com/droonga/fluent-plugin-droonga/commit/352e712043595b3c14684fa7d386d217220be8f8

  Message:
    Define error classes under the namespace "Droonga::ErrorMessage"

  Modified files:
    lib/droonga/catalog/base.rb
    lib/droonga/dispatcher.rb
    lib/droonga/distributed_command_planner.rb
    lib/droonga/handler_runner.rb
    lib/droonga/plugins/crud.rb
    lib/droonga/plugins/error.rb
    lib/droonga/searcher.rb
  Renamed files:
    lib/droonga/error_message.rb
      (from lib/droonga/message_processing_error.rb)

  Modified: lib/droonga/catalog/base.rb (+1 -1)
===================================================================
--- lib/droonga/catalog/base.rb    2014-02-19 14:51:03 +0900 (fcfdbbf)
+++ lib/droonga/catalog/base.rb    2014-02-19 15:50:51 +0900 (03464b4)
@@ -16,7 +16,7 @@
 require "digest/sha1"
 require "zlib"
 require "time"
-require "droonga/message_processing_error"
+require "droonga/error_message"
 require "droonga/catalog/errors"
 
 module Droonga

  Modified: lib/droonga/dispatcher.rb (+3 -3)
===================================================================
--- lib/droonga/dispatcher.rb    2014-02-19 14:51:03 +0900 (6c6bec8)
+++ lib/droonga/dispatcher.rb    2014-02-19 15:50:51 +0900 (040e72d)
@@ -22,7 +22,7 @@ require "droonga/collector_runner"
 require "droonga/farm"
 require "droonga/session"
 require "droonga/replier"
-require "droonga/message_processing_error"
+require "droonga/error_message"
 require "droonga/distributor"
 
 module Droonga
@@ -96,12 +96,12 @@ module Droonga
         begin
           assert_valid_message(message)
           process_input_message(message)
-        rescue MessageProcessingError => error
+        rescue ErrorMessage::Error => error
           reply("statusCode" => error.status_code,
                 "body"       => error.response_body)
         rescue StandardError, LoadError, SyntaxError => error
           Logger.error("failed to process input message", error)
-          formatted_error = MessageProcessingError.new("Unknown internal error")
+          formatted_error = ErrorMessage::InternalServerError.new("Unknown internal error")
           reply("statusCode" => formatted_error.status_code,
                 "body"       => formatted_error.response_body)
           raise error

  Modified: lib/droonga/distributed_command_planner.rb (+1 -1)
===================================================================
--- lib/droonga/distributed_command_planner.rb    2014-02-19 14:51:03 +0900 (6928afd)
+++ lib/droonga/distributed_command_planner.rb    2014-02-19 15:50:51 +0900 (f492641)
@@ -127,7 +127,7 @@ module Droonga
     def fixed_processor
       @processor["outputs"] = @outputs
       if @processor["type"] == "scatter"
-        raise MessageProcessingError.new("missing key") unless @key
+        raise ErrorMessage::InternalServerError.new("missing key") unless @key
         @processor["key"] = @key
       end
       @processor

  Renamed: lib/droonga/error_message.rb (+10 -4) 88%
===================================================================
--- lib/droonga/message_processing_error.rb    2014-02-19 14:51:03 +0900 (58866da)
+++ lib/droonga/error_message.rb    2014-02-19 15:50:51 +0900 (33cce22)
@@ -17,8 +17,9 @@ require "droonga/error"
 require "droonga/status_code"
 
 module Droonga
-  class MessageProcessingError < Error
-    STATUS_CODE = StatusCode::INTERNAL_SERVER_ERROR
+  module ErrorMessage
+  class Error < Droonga::Error
+    STATUS_CODE = nil
 
     attr_reader :detail
 
@@ -45,11 +46,16 @@ module Droonga
     end
   end
 
-  class BadRequest < MessageProcessingError
+  class InternalServerError < Error
+    STATUS_CODE = StatusCode::INTERNAL_SERVER_ERROR
+  end
+
+  class BadRequest < Error
     STATUS_CODE = StatusCode::BAD_REQUEST
   end
 
-  class NotFound < MessageProcessingError
+  class NotFound < Error
     STATUS_CODE = StatusCode::NOT_FOUND
   end
+  end
 end

  Modified: lib/droonga/handler_runner.rb (+1 -1)
===================================================================
--- lib/droonga/handler_runner.rb    2014-02-19 14:51:03 +0900 (d00083c)
+++ lib/droonga/handler_runner.rb    2014-02-19 15:50:51 +0900 (0338f5f)
@@ -96,7 +96,7 @@ module Droonga
       handler = handler_class.new(@name, @context)
       begin
         handler.handle(handler_message, messenger)
-      rescue MessageProcessingError => error
+      rescue ErrorMessage::Error => error
         messenger.error(error.status_code, error.response_body)
       end
     end

  Modified: lib/droonga/plugins/crud.rb (+1 -1)
===================================================================
--- lib/droonga/plugins/crud.rb    2014-02-19 14:51:03 +0900 (f497d92)
+++ lib/droonga/plugins/crud.rb    2014-02-19 15:50:51 +0900 (a85b4f7)
@@ -16,7 +16,7 @@
 require "groonga"
 
 require "droonga/plugin"
-require "droonga/message_processing_error"
+require "droonga/error_message"
 
 module Droonga
   module Plugins

  Modified: lib/droonga/plugins/error.rb (+1 -1)
===================================================================
--- lib/droonga/plugins/error.rb    2014-02-19 14:51:03 +0900 (03df29a)
+++ lib/droonga/plugins/error.rb    2014-02-19 15:50:51 +0900 (9435dca)
@@ -36,7 +36,7 @@ module Droonga
             if status_codes.size == 1
               output_message.status_code = status_codes.first
             else
-              output_message.status_code = MessageProcessingError::STATUS_CODE
+              output_message.status_code = ErrorMessage::InternalServerError::STATUS_CODE
             end
 
             output_message.body = errors.values.first["body"]

  Modified: lib/droonga/searcher.rb (+1 -1)
===================================================================
--- lib/droonga/searcher.rb    2014-02-19 14:51:03 +0900 (0758e19)
+++ lib/droonga/searcher.rb    2014-02-19 15:50:51 +0900 (81b14a9)
@@ -20,7 +20,7 @@ require "tsort"
 require "groonga"
 
 require "droonga/time_formatter"
-require "droonga/message_processing_error"
+require "droonga/error_message"
 
 module Droonga
   class Searcher
-------------- next part --------------
HTML����������������������������...
Descargar 



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