Descendents of class Exception are used to communicate between raise methods and rescue statements in begin/end blocks. Exception objects carry information about the exception—its type (the exception’s class name), an optional descriptive string, and optional traceback information. Programs may subclass Exception to add additional information.
Register or
log in
to add new notes.
Soleone -
February 12, 2009
![Default_avatar_30](https://www.gravatar.com/avatar/64ac4afdcf405be710b07ec4a8679a74?size=30&default=http://apidock.com/images/default_avatar_30.png)
2 thanks
Use this!
You should raise your own ArgumentError in methods to notify users of your class, if you think certain kinds of arguments aren’t acceptable.
def transfer_money(amount) unless amount.is_a?(Number) raise ArgumentError.new("Only numbers are allowed") end # ... Do the actual work end