Exceptions

From Reia

Jump to: navigation, search

Fair warning: Exceptions are likely to change dramatically as the language develops. The functionality provided at present is the bare minimum to be useful and is certain to change.

Try and catch

Try allows you to enclose some code and handle exceptions that occur while it's executing:

Example:

try
  statement1
  statement2
  statement3
catch ex
  puts "An error occurred: " + ex.to_s()

Throw

Throw raises a value as an exception that can be caught by a try/catch statement.

Example:

throw "I'm an exception"
Personal tools