In Files

  • error.c

Parent

Namespace

Methods

NameError

Public Class Methods

new(msg [, name]) => name_error click to toggle source

Construct a new NameError exception. If given the name parameter may subsequently be examined using the NameError.name method.

 
               static VALUE
name_err_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE name;

    name = (argc > 1) ? argv[--argc] : Qnil;
    rb_call_super(argc, argv);
    rb_iv_set(self, "name", name);
    return self;
}
            

Public Instance Methods

name => string or nil click to toggle source

Return the name associated with this NameError exception.

 
               static VALUE
name_err_name(VALUE self)
{
    return rb_attr_get(self, rb_intern("name"));
}
            
to_s => string click to toggle source

Produce a nicely-formatted string representing the NameError.

 
               static VALUE
name_err_to_s(VALUE exc)
{
    VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
    VALUE str = mesg;

    if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
    StringValue(str);
    if (str != mesg) {
        rb_iv_set(exc, "mesg", mesg = str);
    }
    if (OBJ_TAINTED(exc)) OBJ_TAINT(mesg);
    return mesg;
}
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus