Built-in Exceptions
Exception and the classes derived from it provide
a variety of fundamental building blocks for handling error
conditions in your Ruby scripts. Of course with the power you know
and love from OOP, you can easily extend and adapt these basic
classes as you see fit.
The following are abstract Exception classes:
ExceptionSuperclass of all exceptions
ScriptErrorError originating from program mistakes
StandardErrorSuperclass of standard error exceptions; caught if no class is specified by rescue
The following are subclasses of StandardError:
ArgumentErrorArgument error (incorrect number of arguments, etc.)
EOFErrorEnd of file reached
FloatDomainErrorFloat calculation error
IndexErrorError related to index.
IOErrorError related to input or output.
LocalJumpErrorError related to break, next, redo, retry, or return from wrong place.
NoMemoryErrorInsufficient memory.
RangeErrorError produced when range exceeded
RegexpErrorRegular expression error
RuntimeErrorGeneral runtime error
SecurityErrorError related to security
SystemCallErrorSuperclass of system call exceptions
SystemStackErrorInsufficient stack area
TypeErrorError produced when types don’t match
ZeroDivisionErrorError produced when attempting to divide by zero
The
following are two subclasses of SystemCallError.
See <sys/errno.h> for details.
Errno::ENOENTFile or directory doesn’t exist
Errno::EPERMInsufficient access rights
The
following are subclasses of ScriptError:
LoadErrorError occurring during the loading of libraries
NameError ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access