Exception: SystemExit
Overview
Raised by exit
to initiate the termination of the script.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Object
constructor
Create a new
SystemExit
exception with the given status and message. -
#status ⇒ Integer
Return the status value associated with this system exit.
-
#success? ⇒ Boolean
Returns
true
if exiting successful,false
if not.
Methods inherited from Exception
#==, #backtrace, #backtrace_locations, #cause, #detailed_message, #exception, exception, #full_message, #inspect, #message, #set_backtrace, #to_s, to_tty?
Constructor Details
#new ⇒ Object #new(status) ⇒ Object #new(status, msg) ⇒ Object #new(msg) ⇒ Object
Create a new SystemExit
exception with the given status and message. Status is true, false, or an integer. If status is not given, true is used.
2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 |
# File 'error.c', line 2224
static VALUE
exit_initialize(int argc, VALUE *argv, VALUE exc)
{
VALUE status;
if (argc > 0) {
status = *argv;
switch (status) {
case Qtrue:
status = INT2FIX(EXIT_SUCCESS);
++argv;
--argc;
break;
case Qfalse:
status = INT2FIX(EXIT_FAILURE);
++argv;
--argc;
break;
default:
status = rb_check_to_int(status);
if (NIL_P(status)) {
status = INT2FIX(EXIT_SUCCESS);
}
else {
#if EXIT_SUCCESS != 0
if (status == INT2FIX(0))
status = INT2FIX(EXIT_SUCCESS);
#endif
++argv;
--argc;
}
break;
}
}
else {
status = INT2FIX(EXIT_SUCCESS);
}
rb_call_super(argc, argv);
rb_ivar_set(exc, id_status, status);
return exc;
}
|
Instance Method Details
#status ⇒ Integer
Return the status value associated with this system exit.
2274 2275 2276 2277 2278 |
# File 'error.c', line 2274
static VALUE
exit_status(VALUE exc)
{
return rb_attr_get(exc, id_status);
}
|
#success? ⇒ Boolean
Returns true
if exiting successful, false
if not.
2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 |
# File 'error.c', line 2288
static VALUE
exit_success_p(VALUE exc)
{
VALUE status_val = rb_attr_get(exc, id_status);
int status;
if (NIL_P(status_val))
return Qtrue;
status = NUM2INT(status_val);
return RBOOL(WIFEXITED(status) && WEXITSTATUS(status) == EXIT_SUCCESS);
}
|