[Groonga-commit] ranguba/groonga-client at 2df51ab [master] Add Error#message

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Nov 5 15:22:42 JST 2014


Kouhei Sutou	2014-11-05 15:22:42 +0900 (Wed, 05 Nov 2014)

  New Revision: 2df51ab3f424c7d762c9be1e93445aa897b119a3
  https://github.com/ranguba/groonga-client/commit/2df51ab3f424c7d762c9be1e93445aa897b119a3

  Message:
    Add Error#message

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

  Modified: lib/groonga/client/response/error.rb (+5 -0)
===================================================================
--- lib/groonga/client/response/error.rb    2014-10-22 14:11:04 +0900 (43906a7)
+++ lib/groonga/client/response/error.rb    2014-11-05 15:22:42 +0900 (800b4c0)
@@ -20,6 +20,11 @@ module Groonga
   class Client
     module Response
       class Error < Base
+        # @return [String] The error message of the error response.
+        # @since 0.1.0
+        def message
+          (header || [0, 0, 0.0, ""])[3]
+        end
       end
     end
   end

  Modified: test/response/test-error.rb (+22 -0)
===================================================================
--- test/response/test-error.rb    2014-10-22 14:11:04 +0900 (7e2c478)
+++ test/response/test-error.rb    2014-11-05 15:22:42 +0900 (ef88773)
@@ -36,4 +36,26 @@ class TestResponseError < Test::Unit::TestCase
       assert_equal(Groonga::Client::Response::Error, response.class)
     end
   end
+
+  class TestMessage < self
+    def test_have_header
+      header = [
+        -22,
+        1396012478.14975,
+        0.00050806999206543,
+        "invalid table name: <Nonexistent>",
+        [
+          ["grn_select", "proc.c", 897],
+        ],
+      ]
+      response = Groonga::Client::Response::Error.new(nil, header, nil)
+      assert_equal("invalid table name: <Nonexistent>",
+                   response.message)
+    end
+
+    def test_no_header
+      response = Groonga::Client::Response::Error.new(nil, nil, nil)
+      assert_equal("", response.message)
+    end
+  end
 end
-------------- next part --------------
HTML����������������������������...
Download 



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