Method: Exception#exception
- Defined in:
- error.c
#exception(*args) ⇒ Object
call-seq:
exc.exception([string]) -> an_exception or exc
With no argument, or if the argument is the same as the receiver, return the receiver. Otherwise, create a new exception object of the same class as the receiver, but with a message equal to string.to_str
.
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 |
# File 'error.c', line 1152
static VALUE
exc_exception(int argc, VALUE *argv, VALUE self)
{
VALUE exc;
argc = rb_check_arity(argc, 0, 1);
if (argc == 0) return self;
if (argc == 1 && self == argv[0]) return self;
exc = rb_obj_clone(self);
rb_ivar_set(exc, id_mesg, argv[0]);
return exc;
}
|