diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2016-02-11 12:41:34 -0800 |
---|---|---|
committer | Joshua Haberman <jhaberman@gmail.com> | 2016-02-11 12:41:34 -0800 |
commit | caf1fb7197ee94c07108fc7cfbca07432b185a28 (patch) | |
tree | 83c11422b63312e782bfa722ea774b0b15b33017 /ruby/ext | |
parent | e088c2cf4b8f1bde0ce39d989d13ab48c3c05480 (diff) | |
parent | 3a5f213cca8dc7a541bd4fe63ea61c7634e44d5a (diff) | |
download | protobuf-caf1fb7197ee94c07108fc7cfbca07432b185a28.tar.gz protobuf-caf1fb7197ee94c07108fc7cfbca07432b185a28.tar.bz2 protobuf-caf1fb7197ee94c07108fc7cfbca07432b185a28.zip |
Merge pull request #997 from anderscarling/better_errors
ruby: Better exception text for common cases
Diffstat (limited to 'ruby/ext')
-rw-r--r-- | ruby/ext/google/protobuf_c/message.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ruby/ext/google/protobuf_c/message.c b/ruby/ext/google/protobuf_c/message.c index ebe2f1ab..283939c9 100644 --- a/ruby/ext/google/protobuf_c/message.c +++ b/ruby/ext/google/protobuf_c/message.c @@ -166,7 +166,7 @@ VALUE Message_method_missing(int argc, VALUE* argv, VALUE _self) { name, name_len); if (f == NULL) { - rb_raise(rb_eArgError, "Unknown field"); + return rb_call_super(argc, argv); } if (setter) { @@ -197,7 +197,7 @@ int Message_initialize_kwarg(VALUE key, VALUE val, VALUE _self) { f = upb_msgdef_ntofz(self->descriptor->msgdef, name); if (f == NULL) { rb_raise(rb_eArgError, - "Unknown field name in initialization map entry."); + "Unknown field name '%s' in initialization map entry.", name); } if (is_map_field(f)) { @@ -205,7 +205,7 @@ int Message_initialize_kwarg(VALUE key, VALUE val, VALUE _self) { if (TYPE(val) != T_HASH) { rb_raise(rb_eArgError, - "Expected Hash object as initializer value for map field."); + "Expected Hash object as initializer value for map field '%s'.", name); } map = layout_get(self->descriptor->layout, Message_data(self), f); Map_merge_into_self(map, val); @@ -214,7 +214,7 @@ int Message_initialize_kwarg(VALUE key, VALUE val, VALUE _self) { if (TYPE(val) != T_ARRAY) { rb_raise(rb_eArgError, - "Expected array as initializer value for repeated field."); + "Expected array as initializer value for repeated field '%s'.", name); } ary = layout_get(self->descriptor->layout, Message_data(self), f); for (int i = 0; i < RARRAY_LEN(val); i++) { |