Exception: NameError
- Inherits:
-
StandardError
- Object
- Exception
- StandardError
- NameError
- Defined in:
- error.c
Direct Known Subclasses
Defined Under Namespace
Classes: message
Instance Method Summary collapse
-
#new(msg[, name]) ⇒ Object
constructor
Construct a new NameError exception.
-
#name ⇒ String?
Return the name associated with this NameError exception.
-
#to_s ⇒ String
Produce a nicely-formated string representing the
NameError
.
Methods inherited from Exception
#backtrace, #exception, exception, #inspect, #message, #set_backtrace, #to_str
Constructor Details
#new(msg[, name]) ⇒ Object
Construct a new NameError exception. If given the name parameter may subsequently be examined using the NameError.name
method.
|
# File 'error.c'
/*
* call-seq:
* NameError.new(msg [, name]) => name_error
*
* Construct a new NameError exception. If given the <i>name</i>
* parameter may subsequently be examined using the <code>NameError.name</code>
* method.
*/
static VALUE
name_err_initialize(argc, argv, self)
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;
}
|
Instance Method Details
#name ⇒ String?
Return the name associated with this NameError exception.
|
# File 'error.c'
/*
* call-seq:
* name_error.name => string or nil
*
* Return the name associated with this NameError exception.
*/
static VALUE
name_err_name(self)
VALUE self;
{
return rb_attr_get(self, rb_intern("name"));
}
|
#to_s ⇒ String
Produce a nicely-formated string representing the NameError
.
|
# File 'error.c'
/*
* call-seq:
* name_error.to_s => string
*
* Produce a nicely-formated string representing the +NameError+.
*/
static VALUE
name_err_to_s(exc)
VALUE exc;
{
VALUE mesg = rb_attr_get(exc, rb_intern("mesg")), 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;
}
|