Exception
Class Exception and its subclasses are used to indicate that an error or other problem has occurred, and may need to be handled. See Exceptions.
An Exception object carries certain information:
-
The type (the exception’s class), commonly
StandardError,RuntimeError, or a subclass of one or the other; see Built-In Exception Class Hierarchy. -
An optional descriptive message; see methods
::new,message. -
Optional backtrace information; see methods
backtrace,backtrace_locations,set_backtrace. -
An optional cause; see method
cause.
Built-In Exception Class Hierarchy
The hierarchy of built-in subclasses of class Exception:
-
-
-
Errno(and its subclasses, representing system errors)
-
Class methods 4
Instance methods 13
Ruby version changes 2
-
3.4
-
Exception#set_backtracenow accepts arrays ofThread::Backtrace::Location.Kernel#raise,Thread#raiseandFiber#raisealso accept this new format. [Feature #13557]
-
-
3.2
-
Exception#detailed_messagehas been added. The default error printer calls this method on theExceptionobject instead of message. [Feature #18564]
-