class method
Exception.new
(?::string | ::_ToS message) -> ::Exception
Exception.new(message = nil) → exception
error.c
View on GitHub ↗
static VALUE
exc_initialize(int argc, VALUE *argv, VALUE exc)
{
VALUE arg;
arg = (!rb_check_arity(argc, 0, 1) ? Qnil : argv[0]);
return exc_init(exc, arg);
}
Returns a new exception object.
The given message should be a string-convertible object; see method message; if not given, the message is the class name of the new instance (which may be the name of a subclass):
Examples:
Example
Exception.new # => #<Exception: Exception> LoadError.new # => #<LoadError: LoadError> # Subclass of Exception. Exception.new('Boom') # => #<Exception: Boom>