ext/rjbexception.c in rjb-1.3.5 vs ext/rjbexception.c in rjb-1.3.6

- old
+ new

@@ -10,11 +10,11 @@ * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * - * $Id: rjbexception.c 126 2010-07-22 13:58:15Z arton $ + * $Id: rjbexception.c 174 2011-11-09 13:47:43Z arton $ */ #include "ruby.h" #include "extconf.h" #if RJB_RUBY_VERSION_CODE < 190 @@ -30,10 +30,16 @@ { ID rmid = rb_to_id(argv[0]); return rb_funcall(rb_ivar_get(self, rb_intern("@cause")), rmid, argc - 1, argv + 1); } +static VALUE exception_to_s(VALUE self) +{ + return rb_funcall(rb_ivar_get(self, rb_intern("@cause")), + rb_intern("toString"), 0); +} + /* * handle Java exception * At this time, the Java exception is defined without the package name. * This design may change in future release. */ @@ -59,9 +65,10 @@ rexp = rb_hash_aref(rjb_loaded_classes, cname); if (rexp == Qnil) { rexp = rb_define_class(pcls, rb_eStandardError); rb_define_method(rexp, "method_missing", missing_delegate, -1); + rb_define_method(rexp, "to_str", exception_to_s, 0); #if defined(HAVE_RB_HASH_ASET) || defined(RUBINIUS) rb_hash_aset(rjb_loaded_classes, cname, rexp); #else #ifdef RHASH_TBL st_insert(RHASH_TBL(rjb_loaded_classes), cname, rexp);