public Method

Exception.inspect

exception.inspect    string

Return this exception’s class name an message

Source Code

/*
* call-seq:
*   exception.inspect   => string
*
* Return this exception's class name an message
*/

static VALUE
exc_inspect(exc)
   VALUE exc;
{
   VALUE str, klass;

   klass = CLASS_OF(exc);
   exc = rb_obj_as_string(exc);
   if (RSTRING(exc)->len == 0) {
       return rb_str_dup(rb_class_name(klass));
   }

   str = rb_str_buf_new2("#<");
   klass = rb_class_name(klass);
   rb_str_buf_append(str, klass);
   rb_str_buf_cat(str, ": ", 2);
   rb_str_buf_append(str, exc);
   rb_str_buf_cat(str, ">", 1);

   return str;
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.