Method: Exception.exception
- Defined in:
.exception ⇒ Object
call-seq:
exception(message = nil) -> self or new_exception
Returns an exception object of the same class as self; useful for creating a similar exception, but with a different message.
With message nil, returns self:
x0 = StandardError.new('Boom') # => #<StandardError: Boom>
x1 = x0.exception # => #<StandardError: Boom>
x0.__id__ == x1.__id__ # => true
With string-convertible object message (even the same as the original message), returns a new exception object whose class is the same as self, and whose message is the given message:
x1 = x0.exception('Boom') # => #<StandardError: Boom>
x0..equal?(x1) # => false