Exceptions

Introduction

The exceptions mechanism is similar to other programming languages.

try {
    if (something)
        throw Exception.new("Error message");
    else if (somethingElse)
        throw MyException.new("Another message");
} catch (MyException me) {
    print(me.msg);
} catch (e) {
    print(e.msg);
}

Going back to execution flow

Code example:

try {
    throw Exception.new("Error message");
    throw MyException.new("Another message");
    print("OK");
} catch (MyException me) {
    print(me.msg);
    resume;
} catch (e) {
    print(e.msg);
}

Will give this result:

Error message
Another message