123456789_123456789_123456789_123456789_123456789_

Exception: Interrupt

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: SignalException
Defined in: error.c,
error.c,
signal.c

Overview

Raised when the interrupt signal is received, typically because the user has pressed Control-C (on most posix platforms). As such, it is a subclass of ::SignalException.

begin
  puts "Press ctrl-C when you get bored"
  loop {}
rescue Interrupt => e
  puts "Note: You will typically use Signal.trap instead."
end

produces:

Press ctrl-C when you get bored

then waits until it is interrupted with Control-C and then prints:

Note: You will typically use Signal.trap instead.

Class Attribute Summary

::Exception - Inherited

.to_tty?

Returns true if exception messages will be sent to a terminal device.

Class Method Summary

::SignalException - Inherited

.new

Construct a new ::SignalException object.

::Exception - Inherited

.exception

Returns an exception object of the same class as self; useful for creating a similar exception, but with a different message.

.new

Returns a new exception object.

Instance Method Summary

::SignalException - Inherited

#signo

Returns a signal number.

::Exception - Inherited

#==

Returns whether object is the same class as self and its #message and #backtrace are equal to those of self.

#backtrace

Returns a backtrace value for self; the returned value depends on the form of the stored backtrace value:

#backtrace_locations

Returns a backtrace value for self; the returned value depends on the form of the stored backtrace value:

#cause

Returns the previous value of global variable $!, which may be nil (see Global Variables):

#detailed_message

Returns the message string with enhancements:

#exception

Returns an exception object of the same class as self; useful for creating a similar exception, but with a different message.

#full_message

Returns an enhanced message string:

#inspect

Returns a string representation of self:

#message

Returns #to_s.

#set_backtrace

Sets the backtrace value for self; returns the given +value:

#to_s

Returns a string representation of self:

Constructor Details

.new(*args)

This method is for internal use only.
[ GitHub ]

  
# File 'signal.c', line 395

static VALUE
interrupt_init(int argc, VALUE *argv, VALUE self)
{
    VALUE args[2];

    args[0] = INT2FIX(SIGINT);
    args[1] = rb_check_arity(argc, 0, 1) ? argv[0] : Qnil;
    return rb_call_super(2, args);
}