[Groonga-commit] ranguba/groonga-client at 0174223 [master] Add Response::Base#error_message

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Mon Mar 28 00:13:51 JST 2016


Kouhei Sutou	2016-03-28 00:13:51 +0900 (Mon, 28 Mar 2016)

  New Revision: 0174223f70017b8cdd256aea2b889c2cdaa89c5d
  https://github.com/ranguba/groonga-client/commit/0174223f70017b8cdd256aea2b889c2cdaa89c5d

  Message:
    Add Response::Base#error_message

  Modified files:
    lib/groonga/client/response/base.rb
    test/response/test-base.rb

  Modified: lib/groonga/client/response/base.rb (+6 -0)
===================================================================
--- lib/groonga/client/response/base.rb    2016-03-22 12:20:45 +0900 (fe2da3e)
+++ lib/groonga/client/response/base.rb    2016-03-28 00:13:51 +0900 (5d5c44e)
@@ -172,6 +172,12 @@ module Groonga
           (header || [0, 0, 0.0])[2]
         end
 
+        # @return [String, nil] The error message of the response.
+        # @since 0.2.4
+        def error_message
+          (header || [0, 0, 0.0, nil])[3]
+        end
+
         # @return [Boolean] `true` if the request is processed successfully,
         #   `false` otherwise.
         # @since 0.1.0

  Modified: test/response/test-base.rb (+19 -0)
===================================================================
--- test/response/test-base.rb    2016-03-22 12:20:45 +0900 (927cdb8)
+++ test/response/test-base.rb    2016-03-28 00:13:51 +0900 (0430315)
@@ -71,6 +71,25 @@ class TestResponseBase < Test::Unit::TestCase
       end
     end
 
+    class TestErrorMessage < self
+      def test_have_header
+        error_message = "invalid argument"
+        header = [
+          -21,
+          1396012478.14975,
+          0.00050806999206543,
+          error_message,
+        ]
+        response = Groonga::Client::Response::Base.new(nil, header, nil)
+        assert_equal(error_message, response.error_message)
+      end
+
+      def test_no_header
+        response = Groonga::Client::Response::Error.new(nil, nil, nil)
+        assert_nil(response.error_message)
+      end
+    end
+
     class TestSuccess < self
       def test_have_header
         header = [
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る