[Groonga-commit] ranguba/rroonga at ac55d84 [master] Put actual value to invalid argument error message

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Nov 5 16:27:39 JST 2016


Kouhei Sutou	2016-11-05 16:27:39 +0900 (Sat, 05 Nov 2016)

  New Revision: ac55d845d0fd62a3566eff5c58ed574e69b5104e
  https://github.com/ranguba/rroonga/commit/ac55d845d0fd62a3566eff5c58ed574e69b5104e

  Message:
    Put actual value to invalid argument error message
    
    It's very helpful to debug.

  Modified files:
    ext/groonga/rb-grn-table.c
    test/test-index-column.rb

  Modified: ext/groonga/rb-grn-table.c (+6 -2)
===================================================================
--- ext/groonga/rb-grn-table.c    2016-11-05 16:25:06 +0900 (e9be518)
+++ ext/groonga/rb-grn-table.c    2016-11-05 16:27:39 +0900 (a49433b)
@@ -451,7 +451,9 @@ rb_grn_table_define_index_column (int argc, VALUE *argv, VALUE self)
 
     if (!NIL_P(rb_size)) {
         if (rb_type(rb_size) != T_SYMBOL) {
-            rb_raise(rb_eArgError, "should pass :small or :medium.");
+            rb_raise(rb_eArgError,
+                     ":size must be nil, :small or :medium: <%" PRIsVALUE ">",
+                     rb_size);
         } else {
             index_size = RSYMBOL2CSTR(rb_size);
         }
@@ -460,7 +462,9 @@ rb_grn_table_define_index_column (int argc, VALUE *argv, VALUE self)
         } else if (strcmp(index_size, "medium") == 0) {
             flags |= GRN_OBJ_INDEX_MEDIUM;
         } else {
-            rb_raise(rb_eArgError, "should pass :small or :medium.");
+            rb_raise(rb_eArgError,
+                     ":size must be nil, :small or :medium: <%" PRIsVALUE ">",
+                     rb_size);
         }
     }
 

  Modified: test/test-index-column.rb (+2 -1)
===================================================================
--- test/test-index-column.rb    2016-11-05 16:25:06 +0900 (dc20fe3)
+++ test/test-index-column.rb    2016-11-05 16:27:39 +0900 (b98f7cb)
@@ -430,7 +430,8 @@ class IndexColumnTest < Test::Unit::TestCase
         Groonga::Schema.create_table("Tags",
                                      :type => :patricia_trie,
                                      :key_type => "ShortText")
-        assert_raise(ArgumentError.new("should pass :small or :medium.")) do
+        message = ":size must be nil, :small or :medium: <invalid>"
+        assert_raise(ArgumentError.new(message)) do
           tags = Groonga["Tags"]
           tags.define_index_column("small", Groonga["Articles"],
                                    :size => "invalid")
-------------- next part --------------
HTML����������������������������...
Descargar 



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