Menu

Exceptions

Mark Anthony Taylor (Shyreman)

Exceptions are caught in a manner similar to C++.

(
    try
    (
        <test-body>
    )
    catch <exception-name>
    (
        <error-handlers>
    )
)

Example:

(
    try
    (
        (Float32 y = (1 / 0))
    )
    catch ex
    (
        (LogExeception ex)
    )
}

test-body is a sequence of s-expressions that could appear in any regular function definition.
If an exception is thrown while the program is within the test-body, then the stack is cleaned up and
execution begins in the error-handlers function. The exception is of type Sys.IException and has
the name exception-name. Exception handling is not particularly expensive in the Sexy scripting
language.

Exceptions are thrown by using the throw keyword:

(IException ex (CreateException "bah!" -1))
(throw ex)

Related

Wiki: Content