Exception is a Quail object that represents an error. Exception can be thrown interrupting execution and caught when thrown to resume execution.
Exception class | Meaning |
---|---|
AssertionException |
Thrown when assert fails |
CircularDependencyException |
Thrown when circular import is detected (see $9.3.3) |
DerivationException |
Thrown when derivation is impossible |
Exception |
Base class for all exceptions |
IndexOutOfBoundsException |
Thrown when you try to access invalid index |
IOException |
Thrown when Java’s java.lang.IOException is thrown |
IterationNotStartedException |
Thrown when you try to access next element, but not started iterating |
IterationStopException |
Thrown when iteration reached end |
UnsuitableTypeException |
Thrown when value is of unsuitable type for this operation |
UnsuitableValueException |
Thrown when value is unsuitable for this operation |
UnsupportedConversionException |
Thrown when requesting conversion is not supported |
UnsupportedIterationException |
Thrown when iteration is requested, but not supported by this object |
UnsupportedOperationException |
Thrown when requested operation is not supported |
UnsupportedStepSubscriptException |
Thrown when subscript with step is not supported |
UnsupportedSubscriptException |
Thrown when subscript is not supported |
UnsupportedUnaryOperationException |
Thrown when requested operation is not supported |
You can inherit exception classes to create your own exceptions
class MyException like Exception {
constructor (this, string message) {
this.message = "MyException says: " + message
}
}
To throw an exception use following syntax:
throw Exception() % { "message" = "This is an exception" }
throw MyException("Hello!")
To catch an exception use following syntax:
try {
# erroneous code
} catch as e {
# exception placed into e
}
try {
# erroneous code
} catch IOException as e {
# only catches IOException, all other are left untouched
}
try {
# erroneous code
} catch IOException as e {
# only catches IOException, all other are left untouched
} catch as e {
# fallback
}
When exception is thrown, a RuntimeStriker (inherits java.lang.Exception
) is issued. Try-catch blocks
neutralize RuntimeStrikers which are carrying exceptions.