63
Ruby Exceptions!

Ruby exceptions

Embed Size (px)

Citation preview

Ruby Exceptions!

Hierarch and usage

NoMemoryError!

NoMemoryError

Raised when memory

allocation fails.

ScriptError!

ScriptError

Superclass for errors raised when a script can

not be executed

ScriptError Hierarch

LoadError

Raised when a file required fails to load

NotImplementedError

Raised when a feature is not

implemented on the current platform

SyntaxError

Raised when encountering Ruby code with an invalid

syntax

SignalException!SignalException!

Raised when a signal is received

SignalException

SignalException Hierarch

Interrupt

Raised with the interrupt signal is received, typically

because the user pressed on Control-C

StandardError!

StandardError

The most standard error types are subclasses of StandardError

StandardError Hierarch

ArgumentError

Raised when the arguments are

wrong

IndexError

Raised when the given index is

invalid.

StopIteration < IndexError

Raised to stop the iteration, in particular by

Enumerator#next

IOError

Raised when an IO operation fails.

EOFError < IOError

Raised by some IO operations when

reaching the end of file, nil for example

LocalJumpError

Raised when Ruby can't yield as

requested

NameError

Raised when a given name is invalid or

undefined

NoMethodError < NameError

Raised when a method is called on a

receiver which doesn't have it

defined

RangeError

Raised when a given numerical value is

out of range

FloatDomainError < RangeError

Raised when attempting to

convert special float values

RegexpError

Raised when given an invalid regexp

expression.

RuntimeError *default for raise

A generic error class raised when an

invalid operation is attempted.

SecurityError

Raised when attempting a potential

unsafe operation, typically when the

$SAFE level is raised above 0.

SystemCallError

SystemCallError is the base class for all low-

level platform-dependent errors.

SystemStackError

Raised in case of a stack overflow.

ThreadError

Raised when an invalid operation is

attempted on a thread.

TypeError

Raised when encountering an

object that is not of the expected type.

ZeroDivisionError

Raised when attempting to divide

an integer by 0

SystemExit!

Raised by exit to initiate the

termination of the script.

fatal – impossible to rescue!

Thanks