Control Structures
These are examples of control structures. You may also be interested in:

 Conditional structures
 Exceptions
 Flow-control structures
 Loops

This task is to give an example of an exception handling routine
and to "throw" a new exception.



Related task

   Exceptions Through Nested Calls


# define custom exception class
# StandardError is base class for all exception classes
class MyError : StandardError {
  def initialize: message {
    # forward to StdError's initialize method
    super initialize: message
  }
}
 
try {
  # raises/throws a new MyError exception within try-block
  MyError new: "my message" . raise!
} catch MyError => e {
  # catch exception
  # this will print "my message"
  e message println
} finally {
  # this will always be executed (as in e.g. Java)
  "This is how exception handling in Fancy works :)" println
}