[Groonga-commit] droonga/droonga-client-ruby at baa446d [master] http: use specific error class for invalid HTTP method case

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jan 20 16:43:44 JST 2014


Kouhei Sutou	2014-01-20 16:43:44 +0900 (Mon, 20 Jan 2014)

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

  Message:
    http: use specific error class for invalid HTTP method case

  Modified files:
    lib/droonga/client/connection/http.rb

  Modified: lib/droonga/client/connection/http.rb (+15 -2)
===================================================================
--- lib/droonga/client/connection/http.rb    2014-01-20 16:39:37 +0900 (e93fd4e)
+++ lib/droonga/client/connection/http.rb    2014-01-20 16:43:44 +0900 (395d5ec)
@@ -20,10 +20,24 @@ require "rack"
 
 require "yajl"
 
+require "droonga/client/connection/error"
+
 module Droonga
   class Client
     module Connection
       class HTTP
+        # The error class for invalid HTTP method case
+        class InvalidHTTPMethodError < Error
+          attr_reader :http_method
+          attr_reader :request_message
+          def initialize(http_method, request_message)
+            @http_method     = http_method
+            @request_message = request_message
+            super("Unsupport HTTP Method: #{@http_method}, " +
+                    "in the message: <#{@request_message.inspect}>")
+          end
+        end
+
         class Request
           def initialize(thread)
             @thread = thread
@@ -153,8 +167,7 @@ module Droonga
             Net::HTTP::Get.new(build_path(message, parameters),
                                http_headers)
           else
-            raise ArgumentError.new("Unsupport HTTP Method: #{http_method}, " +
-                                      "in the message: <#{message.inspect}>")
+            raise InvalidHTTPMethodError.new(http_method, message)
           end
         end
 
-------------- next part --------------
HTML����������������������������...
다운로드 



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