Skip to content
class method

Exception.new

(?::string | ::_ToS message) -> ::Exception
Exception.new(message = nil) → exception

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>
See also .json_create .to_tty? .exception #== also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0