[Groonga-commit] droonga/fluent-plugin-droonga at 792404a [master] Define status code by the error class

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Dec 26 11:55:48 JST 2013


YUKI Hiroshi	2013-12-26 11:55:48 +0900 (Thu, 26 Dec 2013)

  New Revision: 792404a3ca7ee1bde64999dc3d9425f1a8f1f8c7
  https://github.com/droonga/fluent-plugin-droonga/commit/792404a3ca7ee1bde64999dc3d9425f1a8f1f8c7

  Merged d5217b2: Merge branch 'master' of 192.168.1.21:~piro/groonga/fluent-plugin-droonga into HEAD

  Message:
    Define status code by the error class

  Modified files:
    lib/droonga/handler_error.rb
    lib/droonga/plugin/handler/add.rb

  Modified: lib/droonga/handler_error.rb (+6 -9)
===================================================================
--- lib/droonga/handler_error.rb    2013-12-26 11:50:34 +0900 (6477619)
+++ lib/droonga/handler_error.rb    2013-12-26 11:55:48 +0900 (e7d0fd5)
@@ -15,28 +15,25 @@
 
 module Droonga
   class HandlerError < StandardError
-    attr_reader :message, :detail, :status
+    attr_reader :message, :detail
 
     def initialize(message, options={})
       @message = message
       @detial = options[:detail] || nil
-      @status_code = options[:status_code] || default_status_code
     end
 
     def name
       self.class.to_s
     end
 
-    private
-    def default_status_code
+    def status_code
       500
     end
+  end
 
-    class HandlerClientError < self
-      private
-      def default_status_code
-        400
-      end
+  class HandlerClientError < HandlerError
+    def status_code
+      400
     end
   end
 end

  Modified: lib/droonga/plugin/handler/add.rb (+5 -1)
===================================================================
--- lib/droonga/plugin/handler/add.rb    2013-12-26 11:50:34 +0900 (117cdec)
+++ lib/droonga/plugin/handler/add.rb    2013-12-26 11:55:48 +0900 (c13baf9)
@@ -23,7 +23,7 @@ module Droonga
   class AddHandler < Droonga::HandlerPlugin
     repository.register("add", self)
 
-    class InvalidRequest < Droonga::HandlerError::HandlerClientError
+    class InvalidRequest < HandlerClientError
     end
 
     class MissingTable < InvalidRequest
@@ -45,6 +45,10 @@ module Droonga
         super("The table #{table_name.inspect} does not exist in the dataset.",
               options)
       end
+
+      def status_code
+        404
+      end
     end
 
     command :add
-------------- next part --------------
HTML����������������������������...
Download 



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